Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit efd8816

Browse files
committed
add extra test vectors for ergo
1 parent 47bae5a commit efd8816

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

autolykos2/autolykos2.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type Config struct {
1919
nIncreasementHeightMax uint64
2020
}
2121

22-
// k = 32, n = 26
2322
func New(k, n int) *Config {
2423
cfg := &Config{
2524
k: k,
@@ -33,6 +32,10 @@ func New(k, n int) *Config {
3332
return cfg
3433
}
3534

35+
func NewErgo() *Config {
36+
return New(32, 26)
37+
}
38+
3639
/* helpers */
3740

3841
func concatBytes(a, b []byte) []byte {

autolykos2/autolykos2_test.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/sencha-dev/powkit/internal/common/testutil"
88
)
99

10-
func TestCalcN(t *testing.T) {
10+
func TestCalcNErgo(t *testing.T) {
1111
tests := []struct {
1212
height uint64
1313
value uint32
@@ -51,31 +51,42 @@ func TestCalcN(t *testing.T) {
5151
}
5252

5353
for i, tt := range tests {
54-
value := New(32, 26).calcN(tt.height)
54+
value := NewErgo().calcN(tt.height)
5555
if value != tt.value {
5656
t.Errorf("failed on %d: have %d, want %d", i, value, tt.value)
5757
}
5858
}
5959
}
6060

61-
func TestCompute(t *testing.T) {
61+
func TestComputeErgo(t *testing.T) {
6262
tests := []struct {
6363
msg []byte
6464
nonce uint64
6565
height uint64
6666
result []byte
6767
}{
68-
// https://www.ergoforum.org/t/test-vectors-for-increased-n-values/2887
6968
{
7069
msg: testutil.MustDecodeHex("548c3e602a8f36f8f2738f5f643b02425038044d98543a51cabaa9785e7e864f"),
7170
nonce: 0x3105,
7271
height: 614400,
7372
result: testutil.MustDecodeHex("0002fcb113fe65e5754959872dfdbffea0489bf830beb4961ddc0e9e66a1412a"),
7473
},
74+
{
75+
msg: testutil.MustDecodeHex("8e26ba46cd2516cce5c0573dc92c6de8f1b7f110bee9aca4d196e5e0e391d029"),
76+
nonce: 0x062360e36e133e4d,
77+
height: 771223,
78+
result: testutil.MustDecodeHex("000000006b216892578fad42f928c9a19638a2abb667a5a8113311393dcca017"),
79+
},
80+
{
81+
msg: testutil.MustDecodeHex("8e26ba46cd2516cce5c0573dc92c6de8f1b7f110bee9aca4d196e5e0e391d029"),
82+
nonce: 0x062360e385ffa5ce,
83+
height: 771223,
84+
result: testutil.MustDecodeHex("0000000005353a7890377419c1ddfdec0e185fa445886597a4ed69e376190aa1"),
85+
},
7586
}
7687

7788
for i, tt := range tests {
78-
result := New(32, 26).Compute(tt.msg, tt.nonce, tt.height)
89+
result := NewErgo().Compute(tt.msg, tt.nonce, tt.height)
7990
if bytes.Compare(result, tt.result) != 0 {
8091
t.Errorf("failed on %d: have %x, want %x", i, result, tt.result)
8192
}

0 commit comments

Comments
 (0)