This commit is contained in:
Henry Case 2018-09-10 17:47:11 +01:00
parent c9af87a89b
commit 73af17b3b1

View File

@ -8,8 +8,8 @@ package main
import "C"
import "fmt"
import rand "crypto/rand"
import sidh "github.com/henrydcase/nobs/dh/sidh"
import sike "github.com/henrydcase/nobs/kem/sike"
import sidh "github.com/cloudflare/p751sidh/sidh"
import sike "github.com/cloudflare/p751sidh/sike"
import "unsafe"
import "runtime"
@ -74,8 +74,7 @@ func keygenCf() (*sidh.PublicKey, *sidh.PrivateKey) {
if err!=nil {
fmt.Errorf("ERR: Generate private key for CF failed")
}
pubKey, _ := sidh.GeneratePublicKey(prvKey)
return pubKey,prvKey
return prvKey.GeneratePublicKey(),prvKey
}
// MSR keygen
@ -154,9 +153,8 @@ func test_cfK_msrK1() {
gPK := pubKey.Export()
for i,v:=range(gPK) {
if byte(cPK[i]) != v {
fmt.Printf("PRV =%d %X\n", len(prvKey.Export()), prvKey.Export())
fmt.Printf("PUB CF =%d %X\n", len(pubKey.Export()), pubKey.Export())
fmt.Printf("PUB MSR=%d %X\n", len(cPK), cPK)
fmt.Printf("Public key B differ")
FailNow()
}
}
}
@ -165,16 +163,13 @@ func test_cfK_msrK1() {
// Check if public key generated with CF is same as the one from MSR
func test_cfK_msrK2() {
pubKeyMsr, prvKey := keygenMsr()
pubKeyCf, err := sidh.GeneratePublicKey(prvKey)
if err != nil {
panic(0)
}
pubKeyCf := prvKey.GeneratePublicKey()
cfPK := pubKeyCf.Export()
msrPK := pubKeyMsr.Export()
for i,v:=range(cfPK) {
if msrPK[i]!= v {
fmt.Printf("Keys differ")
fmt.Printf("Public key B differ")
FailNow()
}
}
@ -235,8 +230,6 @@ func test_cfK_msrE_msrD() {
for i,_:=range(cSS) {
if cSS[i] != cSS2[i] {//gSS[i] != byte(cSS[i]) {
fmt.Printf("LEN=%d %X\n", len(cSS2), cSS2)
fmt.Printf("LEN=%d %X\n", len(cSS), cSS)
fmt.Println("ERR: shared secrets differ")
FailNow()
}
@ -366,6 +359,7 @@ func doLongTest() {
}
func main() {
debug()
for i:=0; i<1000; i++ {
doLongTest()
}