Last active
August 29, 2015 14:02
-
-
Save dchest/226c207b62c6b9c144b6 to your computer and use it in GitHub Desktop.
This program generates random test vectors for curve25519 scalarmult based on Go's NaCl implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"crypto/rand" | |
"code.google.com/p/go.crypto/nacl/box" | |
"code.google.com/p/go.crypto/curve25519" | |
) | |
func main() { | |
for i := 0; i < 1024; i++ { | |
pk1, sk1, err := box.GenerateKey(rand.Reader) | |
if err != nil { | |
panic(err) | |
} | |
pk2, sk2, err := box.GenerateKey(rand.Reader) | |
if err != nil { | |
panic(err) | |
} | |
var out1, out2 [32]byte | |
curve25519.ScalarMult(&out1, sk1, pk2) | |
curve25519.ScalarMult(&out2, sk2, pk1) | |
if out1 != out2 { | |
panic("differ") | |
} | |
fmt.Printf("%x:%x:%x:%x:%x\n", pk1[:], sk1[:], pk2[:], sk2[:], out1[:]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment