| ... | ... | @@ -392,16 +392,17 @@ pub const Ed25519 = struct { |
| 392 | 392 | /// If set, should be something unique for each message, such as a |
| 393 | 393 | /// random nonce, or a counter. |
| 394 | 394 | noise: ?[noise_length]u8, |
| 395 | | /// Filled with cryptographically secure randomness. |
| 396 | | entropy: *const [noise_length]u8, |
| 395 | io: std.Io, |
| 397 | 396 | ) (IdentityElementError || KeyMismatchError || NonCanonicalError || WeakPublicKeyError)!Signer { |
| 398 | 397 | if (!mem.eql(u8, &key_pair.secret_key.publicKeyBytes(), &key_pair.public_key.toBytes())) { |
| 399 | 398 | return error.KeyMismatch; |
| 400 | 399 | } |
| 401 | 400 | const scalar_and_prefix = key_pair.secret_key.scalarAndPrefix(); |
| 401 | var entropy: [noise_length]u8 = undefined; |
| 402 | io.random(&entropy); |
| 402 | 403 | var h = Sha512.init(.{}); |
| 403 | 404 | h.update(&scalar_and_prefix.prefix); |
| 404 | | h.update(entropy); |
| 405 | h.update(&entropy); |
| 405 | 406 | if (noise) |*z| { |
| 406 | 407 | h.update(z); |
| 407 | 408 | } |
| ... | ... | @@ -748,9 +749,7 @@ test "signatures with streaming" { |
| 748 | 749 | const io = std.testing.io; |
| 749 | 750 | const kp = Ed25519.KeyPair.generate(io); |
| 750 | 751 | |
| 751 | | var entropy: [Ed25519.noise_length]u8 = undefined; |
| 752 | | io.random(&entropy); |
| 753 | | var signer = try kp.signer(null, &entropy); |
| 752 | var signer = try kp.signer(null, io); |
| 754 | 753 | signer.update("mes"); |
| 755 | 754 | signer.update("sage"); |
| 756 | 755 | const sig = signer.finalize(); |