Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
887902ea
Unverified
Commit
887902ea
authored
Aug 25, 2021
by
Guillaume Ballet
Committed by
GitHub
Aug 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypto/cloudflare/bn256: fix in-place addition and unmarshalling (#23419)
parent
d1621422
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
6 deletions
+20
-6
bn256_test.go
crypto/bn256/cloudflare/bn256_test.go
+13
-0
curve.go
crypto/bn256/cloudflare/curve.go
+3
-3
gfp.go
crypto/bn256/cloudflare/gfp.go
+1
-0
twist.go
crypto/bn256/cloudflare/twist.go
+3
-3
No files found.
crypto/bn256/cloudflare/bn256_test.go
View file @
887902ea
...
...
@@ -92,6 +92,19 @@ func TestTripartiteDiffieHellman(t *testing.T) {
}
}
func
TestG2SelfAddition
(
t
*
testing
.
T
)
{
s
,
_
:=
rand
.
Int
(
rand
.
Reader
,
Order
)
p
:=
new
(
G2
)
.
ScalarBaseMult
(
s
)
if
!
p
.
p
.
IsOnCurve
()
{
t
.
Fatal
(
"p isn't on curve"
)
}
m
:=
p
.
Add
(
p
,
p
)
.
Marshal
()
if
_
,
err
:=
p
.
Unmarshal
(
m
);
err
!=
nil
{
t
.
Fatalf
(
"p.Add(p, p) ∉ G₂: %v"
,
err
)
}
}
func
BenchmarkG1
(
b
*
testing
.
B
)
{
x
,
_
:=
rand
.
Int
(
rand
.
Reader
,
Order
)
b
.
ResetTimer
()
...
...
crypto/bn256/cloudflare/curve.go
View file @
887902ea
...
...
@@ -171,15 +171,15 @@ func (c *curvePoint) Double(a *curvePoint) {
gfpAdd
(
t
,
d
,
d
)
gfpSub
(
&
c
.
x
,
f
,
t
)
gfpMul
(
&
c
.
z
,
&
a
.
y
,
&
a
.
z
)
gfpAdd
(
&
c
.
z
,
&
c
.
z
,
&
c
.
z
)
gfpAdd
(
t
,
C
,
C
)
gfpAdd
(
t2
,
t
,
t
)
gfpAdd
(
t
,
t2
,
t2
)
gfpSub
(
&
c
.
y
,
d
,
&
c
.
x
)
gfpMul
(
t2
,
e
,
&
c
.
y
)
gfpSub
(
&
c
.
y
,
t2
,
t
)
gfpMul
(
t
,
&
a
.
y
,
&
a
.
z
)
gfpAdd
(
&
c
.
z
,
t
,
t
)
}
func
(
c
*
curvePoint
)
Mul
(
a
*
curvePoint
,
scalar
*
big
.
Int
)
{
...
...
crypto/bn256/cloudflare/gfp.go
View file @
887902ea
...
...
@@ -61,6 +61,7 @@ func (e *gfP) Marshal(out []byte) {
func
(
e
*
gfP
)
Unmarshal
(
in
[]
byte
)
error
{
// Unmarshal the bytes into little endian form
for
w
:=
uint
(
0
);
w
<
4
;
w
++
{
e
[
3
-
w
]
=
0
for
b
:=
uint
(
0
);
b
<
8
;
b
++
{
e
[
3
-
w
]
+=
uint64
(
in
[
8
*
w
+
b
])
<<
(
56
-
8
*
b
)
}
...
...
crypto/bn256/cloudflare/twist.go
View file @
887902ea
...
...
@@ -150,15 +150,15 @@ func (c *twistPoint) Double(a *twistPoint) {
t
.
Add
(
d
,
d
)
c
.
x
.
Sub
(
f
,
t
)
c
.
z
.
Mul
(
&
a
.
y
,
&
a
.
z
)
c
.
z
.
Add
(
&
c
.
z
,
&
c
.
z
)
t
.
Add
(
C
,
C
)
t2
.
Add
(
t
,
t
)
t
.
Add
(
t2
,
t2
)
c
.
y
.
Sub
(
d
,
&
c
.
x
)
t2
.
Mul
(
e
,
&
c
.
y
)
c
.
y
.
Sub
(
t2
,
t
)
t
.
Mul
(
&
a
.
y
,
&
a
.
z
)
c
.
z
.
Add
(
t
,
t
)
}
func
(
c
*
twistPoint
)
Mul
(
a
*
twistPoint
,
scalar
*
big
.
Int
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment