-
Notifications
You must be signed in to change notification settings - Fork 1
/
fs_test.go
52 lines (44 loc) · 937 Bytes
/
fs_test.go
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Package bulletproofs
// Copyright 2024 Distributed Lab. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package bulletproofs
import (
"github.com/cloudflare/bn256"
"github.com/ethereum/go-ethereum/crypto"
"math/big"
"testing"
)
func TestKeccakFS(t *testing.T) {
fs := NewKeccakFS()
fs.AddNumber(bint(1))
fs.AddNumber(bint(2))
c1 := fs.GetChallenge()
c2 := new(big.Int).Mod(
new(big.Int).SetBytes(
crypto.Keccak256(
scalarTo32Byte(bint(1)),
scalarTo32Byte(bint(2)),
),
),
bn256.Order,
)
if c1.Cmp(c2) != 0 {
panic("test failed")
}
fs.AddNumber(bint(3))
c3 := fs.GetChallenge()
c4 := new(big.Int).Mod(
new(big.Int).SetBytes(
crypto.Keccak256(
scalarTo32Byte(bint(1)),
scalarTo32Byte(bint(2)),
scalarTo32Byte(bint(3)),
),
),
bn256.Order,
)
if c3.Cmp(c4) != 0 {
panic("test failed")
}
}