-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcurve.go
More file actions
36 lines (28 loc) · 756 Bytes
/
Copy pathcurve.go
File metadata and controls
36 lines (28 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Package pedersen
// Copyright 2023 Oleg Fomenko. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pedersen
import (
"math/big"
bn256 "github.com/ethereum/go-ethereum/crypto/bn256/cloudflare"
)
var G *bn256.G1
var H *bn256.G1
func ScalarMul(p *bn256.G1, k *big.Int) *bn256.G1 {
return new(bn256.G1).ScalarMult(p, k)
}
func Add(a, b *bn256.G1) *bn256.G1 {
return new(bn256.G1).Add(a, b)
}
func Sub(a, b *bn256.G1) *bn256.G1 {
return Add(a, new(bn256.G1).Neg(b))
}
func X(p *bn256.G1) *big.Int {
bytes := p.Marshal()
return new(big.Int).SetBytes(bytes[:32])
}
func Y(p *bn256.G1) *big.Int {
bytes := p.Marshal()
return new(big.Int).SetBytes(bytes[32:])
}