Skip to content

Commit

Permalink
generate deterministic key with a given seed
Browse files Browse the repository at this point in the history
  • Loading branch information
cmenginnz committed May 15, 2023
1 parent ce307e5 commit 85a7d96
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion share/ccrypto/determ_rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ func (d *determRand) Read(b []byte) (int, error) {
for n < l {
next, out := hash(d.next)
n += copy(b[n:], out)
d.next = next

// In Golang 1.20, ecdsa.GenerateKey() introduced a function called
// MaybeReadRand() which reads 1 byte from the determRand reader
// with 50% chance. As a result, GenerateKey() generates
// nondeterministic keys.
// The following conditional check neutralizes this effect.
if l > 1 {
d.next = next
}
}
return n, nil
}
Expand Down

0 comments on commit 85a7d96

Please sign in to comment.