Git Product home page Git Product logo

Comments (11)

nnsgmsone avatar nnsgmsone commented on June 18, 2024

设P=(x P , y P )是定义在F p 上椭圆曲线E:y 2 = x 3 + ax + b上的一个点,ỹ P 为y P 的最右边的一个比特,
则点P可由x P 和比特ỹ P 表示。
由x P 和ỹ P 恢复y P 的方法如下:
a) 计算域元素α=(x P 3 + ax P + b) modp;
b) 计算α modp的平方根β(参见附录B.1.4),若输出是“不存在平方根”,则报错;
c) 若β的最右边比特等于ỹ P ,则置y P =β;否则置y P = p − β。
我看的是这个。。。莫非我们看的标准不是同一个吗??

from gmsm.

zruijie avatar zruijie commented on June 18, 2024

我们看的是同一个标准,你摘录的应该是GB/T 32918.1-2016 的A5.2 节的内容。但是这节的内容标题是:F_p上椭圆曲线点的压缩与解压缩方法。而4.2.9的描述中主要是点到字节串的转换,而sm2.go的实现部分是:

func Compress(a *PublicKey) []byte {
	buf := []byte{}
	yp := getLastBit(a.Y)
	buf = append(buf, a.X.Bytes()...)
	if n := len(a.X.Bytes()); n < 32 {
		buf = append(zeroByteSlice[:(32-n)], buf...)
	}
	buf = append([]byte{byte(yp)}, buf...)
	return buf
}

该函数输出是字节串,因此我认为应该以02或03开头。

from gmsm.

zruijie avatar zruijie commented on June 18, 2024

Compress函数输入是一个点,那么输出既然是字节串,那么也应该加上02或03

from gmsm.

nnsgmsone avatar nnsgmsone commented on June 18, 2024

那我空了看看吧。。。哈哈,可能看漏了。。。不过我看商业的实现貌似不是bit是byte。。这个是什么情况呢。。。兄台你们取的是Bit还是byte

from gmsm.

zruijie avatar zruijie commented on June 18, 2024

byte

from gmsm.

nnsgmsone avatar nnsgmsone commented on June 18, 2024

好吧。。那我空了改一下。。。不过最近很忙

from gmsm.

nnsgmsone avatar nnsgmsone commented on June 18, 2024

多谢指正啊

from gmsm.

nnsgmsone avatar nnsgmsone commented on June 18, 2024

话说你是巴比特的人?

from gmsm.

zruijie avatar zruijie commented on June 18, 2024

是的,但是比原链和巴比特其实属于公司的不同的产品线

from gmsm.

nnsgmsone avatar nnsgmsone commented on June 18, 2024

from gmsm.

scplwq avatar scplwq commented on June 18, 2024

mmm, 看上去这个 issue 还在..

from gmsm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.