Skip to content

Commit f60596b

Browse files
authored
Merge pull request #959 from openmina/fix-vrf
Fix vrf
2 parents ac0427b + aa00de1 commit f60596b

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,29 @@ jobs:
7777
cd ledger
7878
cargo test --release -- -Z unstable-options --report-time
7979
80+
vrf-tests:
81+
runs-on: ubuntu-20.04
82+
steps:
83+
- name: Git checkout
84+
uses: actions/checkout@v4
85+
- name: Setup build dependencies
86+
run: |
87+
sudo apt update
88+
sudo apt install -y protobuf-compiler
89+
- name: Setup Rust
90+
run: |
91+
# Nightly to be able to use `--report-time` below
92+
rustup install nightly
93+
rustup override set nightly
94+
- name: Build vrf tests
95+
run: |
96+
cd vrf
97+
cargo build --release --tests
98+
- name: Run vrf tests
99+
run: |
100+
cd vrf
101+
cargo test --release -- -Z unstable-options --report-time
102+
80103
tx-fuzzer-check:
81104
runs-on: ubuntu-20.04
82105
steps:

vrf/src/message.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ark_ff::{One, SquareRootField, Zero};
22

3-
use ledger::ToInputs;
3+
use ledger::{proofs::transaction::legacy_input::to_bits, ToInputs};
44
use mina_curves::pasta::curves::pallas::Pallas as CurvePoint;
55
use mina_p2p_messages::v2::EpochSeed;
66
use o1_utils::FieldHelpers;
@@ -98,13 +98,9 @@ impl ToInputs for VrfMessage {
9898
}
9999
};
100100
inputs.append_field(epoch_seed);
101-
for i in (0..LEDGER_DEPTH).rev() {
102-
if self.delegator_index >> i & 1u64 == 1 {
103-
inputs.append_bool(true);
104-
} else {
105-
inputs.append_bool(false);
106-
}
107-
}
108101
inputs.append_u32(self.global_slot);
102+
for bit in to_bits::<_, LEDGER_DEPTH>(self.delegator_index) {
103+
inputs.append_bool(bit);
104+
}
109105
}
110106
}

vrf/src/output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ mod test {
157157
let converted = ConsensusVrfOutputTruncatedStableV1::from(vrf_output);
158158
let converted_string = serde_json::to_string_pretty(&converted).unwrap();
159159
let converted_string_deser: String = serde_json::from_str(&converted_string).unwrap();
160-
let expected = String::from("48H9Qk4D6RzS9kAJQX9HCDjiJ5qLiopxgxaS6xbDCWNaKQMQ9Y4C");
160+
let expected = String::from("39cyg4ZmMtnb_aFUIerNAoAJV8qtkfOpq0zFzPspjgM=");
161161

162162
assert_eq!(expected, converted_string_deser);
163163
}

0 commit comments

Comments
 (0)