benhyland / partial-pass Goto Github PK
View Code? Open in Web Editor NEWPartial passwords implemented using threshold secret sharing.
Partial passwords implemented using threshold secret sharing.
@benhyland First of all, thanks for putting your work onto Github, as I have found it enormously useful in improving my understanding of this algorithm.
Not sure whether you are still interested in this repo, but I thought you might like to know;
The method used here of signing shares with |+| can allow successful authentication with transposed characters.
It seems like it's possible to avoid this by signing shares with |*| when sharing and reversing with |/| when authenticating instead.
case class Password(pw: String, indices: List[Int], from: Int, to: Int)
val passwordGen = for {
// Generate a length between 4 and 8
l <- Gen.choose(4, 8)
// Generate a list of characters of the chosen length in the ASCII printable range
p <- Gen.listOfN(l, Gen.choose[Char]('\u0020', '\u007e'))
// Choose distinct random indices between 0 and the max index
a <- Gen.choose(0, l - 1)
b <- Gen.choose(0, l - 1).suchThat(b => b != a)
c <- Gen.choose(0, l - 1).suchThat(c => c != a && c != b)
d <- Gen.choose(0, l - 1).suchThat(d => d != a && d != b && d != c)
// Choose two indices to transpose
from <- Gen.oneOf(a, b, c, d)
to <- Gen.oneOf(a, b, c, d).suchThat(to => to != from)
} yield Password(p.mkString, List(a, b, c, d), from, to)
test("transposed password characters") {
forAll(passwordGen) { pw: Password =>
whenever(pw.pw(pw.from) != pw.pw(pw.to)) {
val pp = new PartialPass(Sharing.random, 128, 4, pw.pw.length)
val shares = pp.share(pw.pw)
val candidate = CandidateShares(
shares.secret,
pw.indices.map(i => shares.shares(i)),
pw.indices.map { i =>
if (i == pw.from)
pw.pw(pw.to)
else if (i == pw.to)
pw.pw(pw.from)
else pw.pw(i)
}.mkString
)
val ok = pp.authenticate(candidate)
ok should be (false)
}
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.