Replies: 1 comment 1 reply
-
这里result已经是*big.Int类型,左移29/28位没有问题,是指result = result * 2^29,或者result = result * 2^28。limbsToBig方法是从高位开始计算的,所以要不停左移,左移的位数是limbs固定的,29, 28,...这样,和每个limb的系数没有关系。
// The value of a field element is:
// x[0] + (x[1] * 2**29) + (x[2] * 2**57) + (x[3] * 2**86) + (x[4] * 2**114) + (x[5] * 2**143) + (x[6] * 2**171) + (x[7] * 2**200) + (x[8] * 2**228)
Original
From:"尼维沙·纳默帝敖"< ***@***.*** >;
Date:2022/1/25 16:24
To:"emmansun/gmsm"< ***@***.*** >;
CC:"Subscribed"< ***@***.*** >;
Subject:[emmansun/gmsm] 关于SM2中p256ReduceCarry进位问题 (Discussion #18)
最近尝试用Rust写SM2,参考和学习您的代码,十分感谢您保留的常量预计算的代码,解决了很多困惑。没学过GO,代码也是边看边理解。
问题:在p256Sum方法中调用p256ReduceCarry后,原29bits宽,可能就变成了30bits宽,原28bits可能变成29bits。这时如果调用p256ToBig方法转换为bigint,依旧是按照29或者28bits左移的话,是否有问题?
&mdash;
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
byteszard
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
最近尝试用Rust写SM2,参考和学习您的代码,十分感谢您保留的常量预计算的代码,解决了很多困惑。没学过GO,代码也是边看边理解。
问题:在p256Sum方法中调用p256ReduceCarry后,原29bits宽,可能就变成了30bits宽,原28bits可能变成29bits。这时如果调用p256ToBig方法转换为bigint,依旧是按照29或者28bits左移的话,是否有问题?
Beta Was this translation helpful? Give feedback.
All reactions