• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vocdoni / vocdoni-node / 11591814128

30 Oct 2024 10:59AM UTC coverage: 62.216% (+0.007%) from 62.209%
11591814128

Pull #1399

github

web-flow
build(deps): bump elliptic in /tree/arbo/testvectors/circom

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.4 to 6.6.0.
- [Commits](https://github.com/indutny/elliptic/compare/v6.5.4...v6.6.0)

---
updated-dependencies:
- dependency-name: elliptic
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #1399: build(deps): bump elliptic from 6.5.4 to 6.6.0 in /tree/arbo/testvectors/circom

16832 of 27054 relevant lines covered (62.22%)

38397.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.84
/util/zk.go
1
package util
2

3
import (
4
        "crypto/sha256"
5
        "math/big"
6

7
        "go.vocdoni.io/dvote/tree/arbo"
8
)
9

10
// bn254BaseField contains the Base Field of the twisted Edwards curve, whose
11
// base field os the scalar field on the curve BN254. It helps to represent
12
// a scalar number into the field.
13
var bn254BaseField, _ = new(big.Int).SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10)
14

15
// BigToFF function returns the finite field representation of the big.Int
16
// provided. It uses Euclidean Modulus and the BN254 curve scalar field to
17
// represent the provided number.
18
func BigToFF(iv *big.Int) *big.Int {
20,462✔
19
        z := big.NewInt(0)
20,462✔
20
        if c := iv.Cmp(bn254BaseField); c == 0 {
20,462✔
21
                return z
×
22
        } else if c != 1 && iv.Cmp(z) != -1 {
30,654✔
23
                return iv
10,192✔
24
        }
10,192✔
25
        return z.Mod(iv, bn254BaseField)
10,270✔
26
}
27

28
// BytesToArboSplit calculates the sha256 hash (32 bytes) of the slice of bytes
29
// provided. Then, splits the hash into a two parts of 16 bytes, swap the
30
// endianess of that parts and encodes they into a two big.Int's.
31
func BytesToArboSplit(input []byte) []*big.Int {
116✔
32
        hash := sha256.Sum256(input)
116✔
33
        return []*big.Int{
116✔
34
                new(big.Int).SetBytes(arbo.SwapEndianness(hash[:16])),
116✔
35
                new(big.Int).SetBytes(arbo.SwapEndianness(hash[16:])),
116✔
36
        }
116✔
37
}
116✔
38

39
// BytesToArboSplitStr function wraps BytesToArbo to return the input as []string.
40
func BytesToArboSplitStr(input []byte) []string {
75✔
41
        arboBytes := BytesToArboSplit(input)
75✔
42
        return []string{arboBytes[0].String(), arboBytes[1].String()}
75✔
43
}
75✔
44

45
// SplittedArboToBytes function receives a slice of big.Int's and returns the
46
func SplittedArboToBytes(input1, input2 *big.Int) []byte {
485✔
47
        // when the last bytes are 0, the SwapEndianness function removes them
485✔
48
        // so we need to add them back until we have 16 bytes in both parts
485✔
49
        b1 := arbo.SwapEndianness(input1.Bytes())
485✔
50
        for len(b1) < 16 {
485✔
51
                b1 = append(b1, 0)
×
52
        }
×
53
        b2 := arbo.SwapEndianness(input2.Bytes())
485✔
54
        for len(b2) < 16 {
485✔
55
                b2 = append(b2, 0)
×
56
        }
×
57
        return append(b1, b2...)
485✔
58
}
59

60
// SplittedArboStrToBytes function wraps SplittedArboToBytes to return the input as []byte
61
func SplittedArboStrToBytes(input1, input2 string) []byte {
485✔
62
        b1 := new(big.Int)
485✔
63
        b1.SetString(input1, 10)
485✔
64
        b2 := new(big.Int)
485✔
65
        b2.SetString(input2, 10)
485✔
66
        return SplittedArboToBytes(b1, b2)
485✔
67
}
485✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc