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