xlcetc / cryptogm

An implement of china crypto standards, including sm2,sm3 ,sm4 and sm9 algorithms.
Other
38 stars 14 forks source link

duplicate symbol p256IsZero when run sm2.GenerateKey #1

Closed manxiaqu closed 4 years ago

manxiaqu commented 4 years ago

I am trying to do some benchmark test between cryptogm with tjfoc/gmsm, But encounter an error 2020/07/23 15:40:32 duplicate symbol p256IsZero (types 1 and 1) in github.com/xlcetc/cryptogm/sm2curve and /usr/local/go/pkg/linux_amd64/crypto/elliptic.a(p256_asm_amd64.o) when I run test code below:


import (
    "crypto/rand"
    "testing"

    csm "github.com/xlcetc/cryptogm/sm/sm2"
)

func BenchmarkSM2_cryptogm_GenerateKey(b *testing.B) {
    for i := 0; i < b.N; i++ {
        csm.GenerateKey(rand.Reader)
    }
}

But It does succeed in a new clean mod and your test files. So I think it may cause by mod dependency, But I am not sure it's correct or not. Here's mod file.

module sample

go 1.13

require (
    github.com/arnaucube/go-snark v0.0.4
    github.com/google/go-cmp v0.5.1 // indirect
    github.com/pkg/errors v0.9.1 // indirect
    github.com/stretchr/testify v1.6.1
    github.com/tjfoc/gmsm v1.3.2
    github.com/xlcetc/cryptogm v0.0.0-20200714063742-a399bbd3158e
    golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
    gotest.tools v2.2.0+incompatible // indirect
)

OS: ubuntu 16.04 Go version: go version go1.13.5 linux/amd64

Do you know how to fix this or to avoid this problem?

Besides, the sm2 in tjfoc/gmsm works fine.

piggypiggy commented 4 years ago

sm2汇编是根据ecdsa改的,里面的函数名称可能有冲突,已经修改了

manxiaqu commented 4 years ago

可以正常运行了