The full codes:

package main

import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"encoding/hex"
"fmt"
"math/big"
)

func main() {
key2, _ := 
hex.DecodeString("646d22e7aee42d44bd15cdf58006359283e1da83c2670b25d44906d03e9ed4eb")
X2, _ := 
new(big.Int).SetString("3842ab25368451a004bb57f2008106aa18578a2887f5a34d17c92a0f6c22241f",
 
16)
Y2, _ := 
new(big.Int).SetString("72be1183f839f5a9e8841873cd074151da8dd5881fffc7668e2c189c142dad4c",
 
16)

priv2, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
aeskey2, _ := priv2.Curve.ScalarMult(X2, Y2, key2)
fmt.Printf("to: %x\n", aeskey2)

}




在 2017年6月1日星期四 UTC+8下午12:01:49,张伟写道:
>
> I am using ECC ScalarMult to get a point. When I use the amd64 accelerated 
> version, the result is wrong; by using the generic version, the result is 
> normal.
> My code is here:
>
> k, _ := 
> hex.DecodeString("646d22e7aee42d44bd15cdf58006359283e1da83c2670b25d44906d03e9ed4eb")
> X, _ := 
> new(big.Int).SetString("3842ab25368451a004bb57f2008106aa18578a2887f5a34d17c92a0f6c22241f",
>  
> 16)
> Y, _ := 
> new(big.Int).SetString("72be1183f839f5a9e8841873cd074151da8dd5881fffc7668e2c189c142dad4c",
>  
> 16)
>
> priv, _ := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
> p, _ := priv.Curve.ScalarMult(X, Y, k)
> fmt.Printf("%x\n", p)
>
>
> I need 
> "D68B74C852C7F4D271AB7ADC8B451943688DCDFA3F4CA37841CE325461AEEB1B169D519667ABB11651FEDDBCF1F4C52A4FF8A93ACE1C270E8523FDC842AFF005",
> but I get 
> "240AD1096C1C7CBF180067AC3F214DE462881FF3FCFC77B7516762E2BD2AA931D7C99D8200DD54B4182D81C77E720151750FAF26FAB6CF89603C57B46B2BDD85"
>
>
> Thanks for your help!
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to