MCPcopy
hub / github.com/tjfoc/gmsm / sm2P256ToBig

Function sm2P256ToBig

sm2/p256.go:1043–1058  ·  view source on GitHub ↗

X = r * R mod P r = X * R' mod P

(X *sm2P256FieldElement)

Source from the content-addressed store, hash-verified

1041// X = r * R mod P
1042// r = X * R' mod P
1043func sm2P256ToBig(X *sm2P256FieldElement) *big.Int {
1044 r, tm := new(big.Int), new(big.Int)
1045 r.SetInt64(int64(X[8]))
1046 for i := 7; i >= 0; i-- {
1047 if (i & 1) == 0 {
1048 r.Lsh(r, 29)
1049 } else {
1050 r.Lsh(r, 28)
1051 }
1052 tm.SetInt64(int64(X[i]))
1053 r.Add(r, tm)
1054 }
1055 r.Mul(r, sm2P256.RInverse)
1056 r.Mod(r, sm2P256.P)
1057 return r
1058}
1059func WNafReversed(wnaf []int8) []int8 {
1060 wnafRev := make([]int8, len(wnaf), len(wnaf))
1061 for i, v := range wnaf {

Callers 7

DecompressFunction · 0.85
ZAFunction · 0.85
IsOnCurveMethod · 0.85
sm2P256PointToAffineFunction · 0.85
sm2P256ToAffineFunction · 0.85
sm2P256PointAddFunction · 0.85
sm2P256PointSubFunction · 0.85

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…