Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add Falcon signature tests. #1257

Merged
merged 197 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 196 commits
Commits
Show all changes
197 commits
Select commit Hold shift + click to select a range
22c6d5e
chore: update crate versions to v0.8.0
bobbinth Oct 12, 2023
07310bf
feat(assembly): allow creation of masl libraries via api
bitwalker Oct 16, 2023
000436a
docs(mdbook): minor change in the bitwise chiplet
MaxMustermann2 Oct 17, 2023
4e44645
feat: introduce std::utils asm module
frisitano Oct 16, 2023
775209f
Merge pull request #1107 from 0xPolygonMiden/frisitano-std-asm-utils
frisitano Oct 18, 2023
5a2169e
refactor(assembly): improve ergonomics of and access to module import…
bitwalker Oct 18, 2023
1252174
feat(assembly): add accessors for common procedure metadata to module…
bitwalker Oct 18, 2023
bd65e6f
Merge pull request #1109 from MaxMustermann2/bitwise-doc-fix
Al-Kindi-0 Oct 19, 2023
a672a52
feat: expand capabiliies of the debug instruction
Fumuran Oct 11, 2023
51e238e
Merge pull request #1103 from 0xPolygonMiden/andrew-expand-debug
Fumuran Oct 19, 2023
8f5c793
doc: minor typos and nit fixes
Al-Kindi-0 Oct 19, 2023
7af0b82
config: add .editorconfig
hackaugusto Oct 19, 2023
299000e
doc: fix typos
Al-Kindi-0 Oct 20, 2023
16d4d2c
Merge pull request #1112 from 0xPolygonMiden/hacka-editorconfig
bobbinth Oct 20, 2023
fb6f69d
Merge pull request #1111 from 0xPolygonMiden/al-minor-doc-fix
bobbinth Oct 20, 2023
7c3f394
chore: pacify rustfmt
bobbinth Oct 23, 2023
24a8aef
Merge pull request #1114 from 0xPolygonMiden/al-minor-doc-fix-logup
bobbinth Oct 23, 2023
6a12d6d
fix: clippy issues and gpu tests
bobbinth Oct 24, 2023
18fdeda
feat: add host event handler
frisitano Oct 23, 2023
ef9a121
Merge pull request #1119 from 0xPolygonMiden/frisitano/host-event-han…
frisitano Oct 24, 2023
b6ce96e
chore: run pre-comimt run --all-files
frisitano Oct 24, 2023
d9c4eb5
feat: implement frocref instruction
Fumuran Oct 17, 2023
05834ca
refactor: fix bug, add tests
Fumuran Oct 24, 2023
15f63e7
docs: add documentation, update changelog
Fumuran Oct 24, 2023
10ed3e3
Merge pull request #1120 from 0xPolygonMiden/frisitano-precommit-sync
bobbinth Oct 24, 2023
321bc2e
refactor: improve test
Fumuran Oct 25, 2023
c52f813
Memory: Create newtype `ContextId` (#1117)
plafer Oct 25, 2023
07c4a81
refactor: make useless procref test usefull
Fumuran Oct 25, 2023
e7ed3e7
feat: add method to Library
Fumuran Oct 25, 2023
0220290
refactor: use module compilation to obtain roots
Fumuran Oct 26, 2023
d77838b
refactor: add default impl
Fumuran Oct 26, 2023
6fd3cf6
Merge pull request #1113 from 0xPolygonMiden/andrew-implement-procref
bobbinth Oct 26, 2023
702fdf0
Merge pull request #1123 from 0xPolygonMiden/andrew-add-get-module-to…
bobbinth Oct 27, 2023
b651b9d
chore: update miden-crypto dependency to next branch
bobbinth Oct 27, 2023
ee3e5e4
feat: support constants as counters in loop
Fumuran Oct 28, 2023
da70f51
chore: use Winterfell 0.7
Al-Kindi-0 Oct 24, 2023
40229e3
Merge pull request #1121 from 0xPolygonMiden/al-migrate-winterfell
bobbinth Oct 29, 2023
c9bf522
feat: introduce event error
frisitano Oct 30, 2023
4cc5b6a
refactor: improve parsing and testing
Fumuran Oct 30, 2023
7ca450e
docs: improve documentation, update changelog
Fumuran Oct 30, 2023
20054cb
Merge pull request #1125 from 0xPolygonMiden/frisitano-event-vault-delta
bobbinth Oct 30, 2023
d76da5d
Merge pull request #1124 from 0xPolygonMiden/andrew-support-constants…
bobbinth Oct 30, 2023
770e1c5
fix: gpu (metal) tests
bobbinth Oct 31, 2023
b9eeb1b
refactor: rename unchecked instructions
Fumuran Oct 27, 2023
4bbbd83
refactor: remove checked instructions
Fumuran Oct 27, 2023
bba6612
docs: update docs and changelog
Fumuran Oct 27, 2023
65a9e58
refactor: fix formatting
Fumuran Oct 27, 2023
7c40354
refactor: improve ops compilation, testing
Fumuran Nov 1, 2023
b421b60
crypto: update api
hackaugusto Nov 1, 2023
ab96617
Merge pull request #1132 from 0xPolygonMiden/hacka-update-crypto-api
bobbinth Nov 1, 2023
dfa3ac4
refactor: improve prepare_bitwise() func
Fumuran Nov 1, 2023
01ee16a
Merge pull request #1115 from 0xPolygonMiden/andrew-remove-checked-ops
bobbinth Nov 2, 2023
ed0e870
Derive `PartialEq, Eq` for `ExecutionError` (#1145)
plafer Nov 9, 2023
5734a82
feat: add extend method to AdviceInputs
frisitano Nov 15, 2023
57d7ddc
fix assert_with_code test
plafer Nov 21, 2023
a032ab4
Merge pull request #1156 from 0xPolygonMiden/plafer-fix-test
bobbinth Nov 22, 2023
68e1681
Merge pull request #1149 from 0xPolygonMiden/frisitano-advice-inputs-…
bobbinth Nov 23, 2023
bd8f84e
docs: update u32 shift and rotate instructions' docs
Fumuran Nov 9, 2023
55ba352
Merge pull request #1144 from 0xPolygonMiden/andrew-update-u32-docs
Fumuran Nov 23, 2023
c979f8a
Update `std::math::u64` according to the new u32 refactoring (#1142)
Fumuran Nov 23, 2023
fc81592
`StackOutputs`: `get_stack_{item, word}()` methods (#1155)
plafer Nov 27, 2023
bd0edfa
test: fix the stdlib tests
Fumuran Nov 28, 2023
350904d
Merge pull request #1164 from 0xPolygonMiden/andrew-stdlib-tests-hotfix
Fumuran Nov 29, 2023
ecb1699
feat: support libraries in REPL
Fumuran Nov 28, 2023
f6bc75f
Merge pull request #1162 from 0xPolygonMiden/andrew-support-stdlib-in…
Fumuran Nov 29, 2023
cf3ae33
fix: allow to use dyn instructions afrer procref
Fumuran Nov 23, 2023
4582326
Merge pull request #1160 from 0xPolygonMiden/andrew-add-procrefed-fun…
Fumuran Nov 29, 2023
ef33131
chore: add hashing example
Fumuran Nov 21, 2023
9d85c41
Merge pull request #1154 from 0xPolygonMiden/andrew-hashing-examples
Fumuran Nov 30, 2023
15fafb7
ExecutionProof: impl Serializable & Deserializable
hackaugusto Dec 1, 2023
4b8b03f
Merge pull request #1166 from 0xPolygonMiden/hacka-executaion-proof-s…
hackaugusto Dec 1, 2023
27c65ee
stackoutputs: add deserializer and size validation
hackaugusto Dec 1, 2023
3d3f01d
Merge pull request #1169 from 0xPolygonMiden/hacka-stack-outputs-serde
hackaugusto Dec 2, 2023
51aa5c2
chore: made AstSerdeOptions constructor const fn
bobbinth Dec 3, 2023
9c3f340
kernel,program: simplify api
hackaugusto Dec 1, 2023
eccf896
assembly: split mod into smaller files
hackaugusto Dec 4, 2023
f7b5093
Merge pull request #1167 from 0xPolygonMiden/hacka-kernel-serde
hackaugusto Dec 4, 2023
ca7de61
Merge pull request #1172 from 0xPolygonMiden/hacka-split-ast-mod
hackaugusto Dec 4, 2023
381329c
CodeBlock,ProgramAst: implement Serialize/Deserialize
hackaugusto Dec 4, 2023
264c6e1
refactor: move serialization methods into ProgramAst struct
bobbinth Dec 7, 2023
777fae9
Merge pull request #1173 from 0xPolygonMiden/hacka-codeblock-programa…
bobbinth Dec 7, 2023
d58122b
chore: update rustyline dependency to latest
bobbinth Dec 13, 2023
7be367d
feat: impl blake3 example
Fumuran Dec 12, 2023
e16f8f1
Merge pull request #1181 from 0xPolygonMiden/andrew-blake3-internal-e…
Fumuran Dec 14, 2023
685fa69
chore: fix typo in ci.yml
bobbinth Dec 24, 2023
e1dfdd9
fix: remove .append(true) in stdlib/md_renderer.rs
bobbinth Dec 24, 2023
b051580
chore: change dependency to crypto crate for RpoRandomCoin
Al-Kindi-0 Dec 20, 2023
9e61e2a
chore: remove dependency on Winter-crypto
Al-Kindi-0 Dec 22, 2023
0e6f9c1
Merge pull request #1183 from 0xPolygonMiden/al-rm-rporandomcoin
bobbinth Jan 5, 2024
8c17205
chore: remove winter-crypto dependency from core/Cargo.toml
bobbinth Jan 5, 2024
ad4481a
chore: remove explicit sve feature flag
bobbinth Jan 6, 2024
8d7b504
docs: fix comments
bobbinth Jan 7, 2024
124e026
feat: add Tracing logger to the VM
Fumuran Nov 1, 2023
78608e5
Merge pull request #1139 from 0xPolygonMiden/andrew-assembler-logging
Fumuran Jan 10, 2024
88779a1
docs: add explanation of field arithmetic
bobbinth Jan 11, 2024
b0e8450
Merge pull request #1192 from 0xPolygonMiden/bobbin-field-docs
bobbinth Jan 11, 2024
d30d508
Fix: typos (#1196)
GoodDaisy Jan 15, 2024
5bf3cc2
feat: add on_assert_failed method to the Host trait
Fumuran Jan 15, 2024
2662639
Merge pull request #1197 from 0xPolygonMiden/andrew-on-assert-failed
bobbinth Jan 15, 2024
01d8984
feat: implement trace instruction
Fumuran Jan 15, 2024
a24f896
feat: add tracing availability check, update docs
Fumuran Jan 17, 2024
a9a1c6a
Merge pull request #1198 from 0xPolygonMiden/andrew-add-tracing-to-host
bobbinth Jan 17, 2024
067d051
feat: add support for hexes in constants
Fumuran Jan 17, 2024
ee45c70
Merge pull request #1199 from 0xPolygonMiden/andrew-support-hex-in-co…
Fumuran Jan 17, 2024
0752ec6
Fix build after `SimpleSmt` change in miden-crypto (#1200)
plafer Jan 18, 2024
211152c
test: Test errors comparing error types instead of string comparision…
scottdieringer Jan 19, 2024
cfccfcc
stdlib: remove out folder contents only
hackaugusto Jan 23, 2024
4b46f73
Merge pull request #1209 from 0xPolygonMiden/hacka-stdlib-build
hackaugusto Jan 25, 2024
bd10b8c
Implement more optimized version of `u32lt` (#1193)
Fumuran Jan 26, 2024
6bf6425
test: Added falcon signature norm squared test.
scottdieringer Jan 29, 2024
fdc25f9
tests: Added diff_mod_q but have type cast problems.
scottdieringer Jan 29, 2024
afdc3f0
chore: fix clippy
bobbinth Jan 29, 2024
02a8d2d
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Jan 30, 2024
5ff9e08
tests: Working on powers of tau but getting memory out of bounds.
scottdieringer Jan 30, 2024
6e790d6
tests: Have probabilistic polynomial multiplication almost figured ou…
scottdieringer Jan 31, 2024
f43ec5e
feat: add the RCOMB1 instruction (#1216)
Al-Kindi-0 Feb 1, 2024
4715014
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 1, 2024
9758c7a
tests: Have the powers of tau test working. Need to refactor the tes…
scottdieringer Feb 1, 2024
1ea0282
tests: Forgot, still need to add probabilistic product test before th…
scottdieringer Feb 1, 2024
6e709a3
fix: bug due to not copying prev stack state (#1227)
Al-Kindi-0 Feb 1, 2024
0a4fa7a
`mpverify`: don't panic when verification fails (#1230)
plafer Feb 1, 2024
0344f8c
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 2, 2024
10c9e9f
tests: Refactored the powers of tau test to not use hardcoded constan…
scottdieringer Feb 2, 2024
f736992
tests: Have a test for probabilistics product, both success and failu…
scottdieringer Feb 5, 2024
5f325e1
tests: Have a better way to test using provided polynomial crate. Ho…
scottdieringer Feb 6, 2024
9dbc690
tests: Figured out that the problem is that the memory has to be set …
scottdieringer Feb 7, 2024
9ca7ab3
`stdlib` `smt` replacement (single key-value leaf only) (#1215)
plafer Feb 7, 2024
38b838f
tests: Have a plan to test the probabilistic polynomial multiplicati…
scottdieringer Feb 8, 2024
a610832
Removes any remnants of `TieredSmt` (#1237)
plafer Feb 8, 2024
e7bd141
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 9, 2024
b2a2eea
tests: Still need to figure out how advice stack works to test probab…
scottdieringer Feb 9, 2024
ac24f8a
tests: Have the structure of the test in place, still need to figure …
scottdieringer Feb 12, 2024
0bfd9a4
tests: Can build probabilistic product test but cannot compile the MA…
scottdieringer Feb 13, 2024
86df182
feat: add simplified chiplet bus column builder
Al-Kindi-0 Nov 7, 2023
65d6f1d
feat: simplify build of chiplet vtable column
Al-Kindi-0 Nov 27, 2023
7798087
feat: simplify the 3 decoder auxiliary columns
Al-Kindi-0 Dec 2, 2023
95a0951
feat: simplify the 3 decoder auxiliary columns
Al-Kindi-0 Dec 2, 2023
28d1921
feat: simplify stack overflow auxiliary column build
Al-Kindi-0 Dec 5, 2023
6874706
chore: remove decoder aux-hints code
Al-Kindi-0 Dec 6, 2023
85c4e26
refactor: decoder auxiliary builder and uniformize the aux builder pa…
Al-Kindi-0 Dec 6, 2023
f153ecf
feat: simplify auxiliary trace building logic
Al-Kindi-0 Dec 7, 2023
9d8259d
feat: consolidate MainTrace and optimize column build
Al-Kindi-0 Dec 21, 2023
3b45caa
feat: consolidate MainTrace and optimize column build
Al-Kindi-0 Dec 21, 2023
05b6855
Trait for auxiliary column build (#1195)
Al-Kindi-0 Jan 19, 2024
38f1d8e
refactor: clean up aux column generator for stack overflow table (#1213)
bobbinth Jan 24, 2024
8b43742
refactor: Deref `MainTrace` type to `ColMatrix` (#1214)
iammadab Jan 29, 2024
bb46153
fix: metal prover compilation
bobbinth Feb 6, 2024
6713175
chore: split up decoder aux column builders into separate files (#1233)
bobbinth Feb 7, 2024
df6d850
Handle additional memory requests made by `RCOMBBASE` (#1229)
Al-Kindi-0 Feb 8, 2024
d1aa43c
Adds Kernel procedure responses (#1246)
Al-Kindi-0 Feb 13, 2024
0df0e6c
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 14, 2024
80eef53
tests: Solved the previous issue of the code not assemblying. Now ha…
scottdieringer Feb 14, 2024
a11888e
refactor: update to be compatible with Winterfell 0.8 (#1234)
Fumuran Feb 14, 2024
85e33d6
chore: update miden-crypto to v0.8 (#1248)
Fumuran Feb 14, 2024
19565fb
chore: minor clippy fixes
bobbinth Feb 14, 2024
0561bff
refactor: update logging messages in the VM (#1235)
Fumuran Feb 14, 2024
f4e3545
test: rcomb_base and falcon test prove-verify (#1232)
Al-Kindi-0 Feb 14, 2024
ae6a264
refactor: add AdviceMap wrapper (#1207)
ginika-chinonso Feb 15, 2024
1cee2c5
feat: add From BTreeMap conversion for AdviceMap
bobbinth Feb 15, 2024
38ac175
feat: export AdviceMap publicly
bobbinth Feb 15, 2024
3f83983
tests: Merge local and next branch.
scottdieringer Feb 15, 2024
3a9055b
tests: The probabilistic product procedure test has an assertion fail…
scottdieringer Feb 15, 2024
808a78c
tests: Have the load_h_s2_product test working but the probabilistic …
scottdieringer Feb 16, 2024
072e945
Remove `smt64` (#1249)
plafer Feb 20, 2024
416f02d
tests:
scottdieringer Feb 20, 2024
4406f44
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 20, 2024
fed3fc0
tests: Have the probabilistic polynomial product test working. Need …
scottdieringer Feb 20, 2024
b3e0727
clippy: fix TryFrom/TryInto warnings
hackaugusto Feb 21, 2024
894aff6
Merge pull request #1254 from 0xPolygonMiden/hacka-fix-tryfrom-tryint…
hackaugusto Feb 21, 2024
11a8d58
tests: Have probabilistic product test working, both success and fail…
scottdieringer Feb 21, 2024
84cc95e
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 21, 2024
d4f537f
tests:
scottdieringer Feb 21, 2024
574c083
tests: Have the probabilistic product test working, now need to add t…
scottdieringer Feb 21, 2024
8b8f91e
tests: Trying to add test for adv_pus_sig.kind but getting error that…
scottdieringer Feb 22, 2024
c718a0a
fix: clippy errors for redundant imports (#1255)
hackaugusto Feb 23, 2024
bc62b38
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 23, 2024
9712a85
tests: Have two tests for the advice decorator signature push. Need …
scottdieringer Feb 23, 2024
d2987f0
tests: Refactored falcon.rs.
scottdieringer Feb 26, 2024
50591fa
tests: Added to diff_mod_q test and added two more advice push sig te…
scottdieringer Feb 26, 2024
c681639
tests: Changed Cargo.toml in stdlib to avoid github check problem.
scottdieringer Feb 26, 2024
86833e0
merge scottdieringer next branch with miden next branch.
scottdieringer Feb 27, 2024
62515bc
tests: Merge local falcon-sig-tests and the next branch.
scottdieringer Feb 27, 2024
076a53c
tests: Remove unessearry changes.
scottdieringer Feb 27, 2024
67b2478
tests: Get rid of changes in assembly that didn't change.
scottdieringer Feb 27, 2024
c81aabb
tests.
scottdieringer Feb 27, 2024
8533aa9
tests.
scottdieringer Feb 27, 2024
3dbc2ab
tests.
scottdieringer Feb 27, 2024
5514c95
tests.
scottdieringer Feb 27, 2024
eb8478b
tests.
scottdieringer Feb 27, 2024
9413148
tests: Fix format.
scottdieringer Feb 27, 2024
759e5dd
tests: Fix format.
scottdieringer Feb 27, 2024
b9e3d54
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Feb 29, 2024
3c2b514
Merge branch 'next' of github.com:scottdieringer/miden-vm into falcon…
scottdieringer Mar 5, 2024
d457ec7
tests: Address PR comment.
scottdieringer Mar 5, 2024
13b635d
test: Addressed merge conflicts with updated miden-crypto-0.9.0.
scottdieringer Mar 29, 2024
07b5a54
test: Addressed PR comments.
scottdieringer Apr 5, 2024
2d7e899
tests: Address PR comment. Dependencies in alphabetical order.
scottdieringer Apr 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions assembly/src/assembler/instruction/u32_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub enum U32OpMode {
pub fn u32testw(span: &mut SpanBuilder) -> Result<Option<CodeBlock>, AssemblyError> {
#[rustfmt::skip]
let ops = [
// Test the fourth element
// Test the fourth element
Dup3, U32split, Swap, Drop, Eqz,

// Test the third element
Expand Down Expand Up @@ -481,23 +481,23 @@ fn calculate_clz(span: &mut SpanBuilder) -> Result<Option<CodeBlock>, AssemblyEr
let ops_group_2 = [
Push(Felt::new(u32::MAX as u64 + 1)), // [2^32, pow2(32 - clz), n, clz, ...]

Dup1, Neg, Add, // [2^32 - pow2(32 - clz), pow2(32 - clz), n, clz, ...]
// `2^32 - pow2(32 - clz)` is equal to `clz` leading ones and `32 - clz`
Dup1, Neg, Add, // [2^32 - pow2(32 - clz), pow2(32 - clz), n, clz, ...]
// `2^32 - pow2(32 - clz)` is equal to `clz` leading ones and `32 - clz`
// zeros:
// 1111111111...1110000...0
// └─ `clz` ones ─┘

Swap, Push(2u8.into()), U32div, Drop, // [pow2(32 - clz) / 2, 2^32 - pow2(32 - clz), n, clz, ...]
// pow2(32 - clz) / 2 is equal to `clz` leading
Swap, Push(2u8.into()), U32div, Drop, // [pow2(32 - clz) / 2, 2^32 - pow2(32 - clz), n, clz, ...]
// pow2(32 - clz) / 2 is equal to `clz` leading
// zeros, `1` one and all other zeros.

Swap, Dup1, Add, // [bit_mask, pow2(32 - clz) / 2, n, clz, ...]
Swap, Dup1, Add, // [bit_mask, pow2(32 - clz) / 2, n, clz, ...]
// 1111111111...111000...0 <-- bitmask
// └─ clz ones ─┘│
// └─ additional one

MovUp2, U32and, // [m, pow2(32 - clz) / 2, clz]
// If calcualtion of `clz` is correct, m should be equal to
MovUp2, U32and, // [m, pow2(32 - clz) / 2, clz]
// If calcualtion of `clz` is correct, m should be equal to
// pow2(32 - clz) / 2

Eq, Assert(0) // [clz, ...]
Expand Down Expand Up @@ -556,23 +556,23 @@ fn calculate_clo(span: &mut SpanBuilder) -> Result<Option<CodeBlock>, AssemblyEr
let ops_group_2 = [
Push(Felt::new(u32::MAX as u64 + 1)), // [2^32, pow2(32 - clo), n, clo, ...]

Dup1, Neg, Add, // [2^32 - pow2(32 - clo), pow2(32 - clo), n, clo, ...]
// `2^32 - pow2(32 - clo)` is equal to `clo` leading ones and `32 - clo`
Dup1, Neg, Add, // [2^32 - pow2(32 - clo), pow2(32 - clo), n, clo, ...]
// `2^32 - pow2(32 - clo)` is equal to `clo` leading ones and `32 - clo`
// zeros:
// 11111111...1110000...0
// └─ clo ones ─┘

Swap, Push(2u8.into()), U32div, Drop, // [pow2(32 - clo) / 2, 2^32 - pow2(32 - clo), n, clo, ...]
// pow2(32 - clo) / 2 is equal to `clo` leading
Swap, Push(2u8.into()), U32div, Drop, // [pow2(32 - clo) / 2, 2^32 - pow2(32 - clo), n, clo, ...]
// pow2(32 - clo) / 2 is equal to `clo` leading
// zeros, `1` one and all other zeros.

Dup1, Add, // [bit_mask, 2^32 - pow2(32 - clo), n, clo, ...]
Dup1, Add, // [bit_mask, 2^32 - pow2(32 - clo), n, clo, ...]
// 111111111...111000...0 <-- bitmask
// └─ clo ones ─┘│
// └─ additional one

MovUp2, U32and, // [m, 2^32 - pow2(32 - clo), clo]
// If calcualtion of `clo` is correct, m should be equal to
MovUp2, U32and, // [m, 2^32 - pow2(32 - clo), clo]
// If calcualtion of `clo` is correct, m should be equal to
// 2^32 - pow2(32 - clo)

Eq, Assert(0) // [clo, ...]
Expand Down Expand Up @@ -630,23 +630,23 @@ fn calculate_ctz(span: &mut SpanBuilder) -> Result<Option<CodeBlock>, AssemblyEr
#[rustfmt::skip]
let ops_group_2 = [
Dup0, // [pow2(ctz), pow2(ctz), n, ctz, ...]
// pow2(ctz) is equal to all zeros with only one on the `ctz`'th trailing position
// pow2(ctz) is equal to all zeros with only one on the `ctz`'th trailing position

Pad, Incr, Neg, Add, // [pow2(ctz) - 1, pow2(ctz), n, ctz, ...]

Swap, U32split, Drop, // [pow2(ctz), pow2(ctz) - 1, n, ctz, ...]
// We need to drop the high bits of `pow2(ctz)` because if `ctz`
// We need to drop the high bits of `pow2(ctz)` because if `ctz`
// equals 32 `pow2(ctz)` will exceed the u32. Also in that case there
// is no need to check the dividing one, since it is absent (value is
// all 0's).
// all 0's).

Dup0, MovUp2, Add, // [bit_mask, pow2(ctz), n, ctz]
// 00..001111111111...11 <-- bitmask
// │└─ ctz ones ─┘
// └─ additional one

MovUp2, U32and, // [m, pow2(ctz), ctz]
// If calcualtion of `ctz` is correct, m should be equal to
// If calcualtion of `ctz` is correct, m should be equal to
// pow2(ctz)

Eq, Assert(0), // [ctz, ...]
Expand Down Expand Up @@ -709,18 +709,18 @@ fn calculate_cto(span: &mut SpanBuilder) -> Result<Option<CodeBlock>, AssemblyEr
Pad, Incr, Neg, Add, // [pow2(cto) - 1, pow2(cto), n, cto, ...]

Swap, U32split, Drop, // [pow2(cto), pow2(cto) - 1, n, cto, ...]
// We need to drop the high bits of `pow2(cto)` because if `cto`
// We need to drop the high bits of `pow2(cto)` because if `cto`
// equals 32 `pow2(cto)` will exceed the u32. Also in that case there
// is no need to check the dividing zero, since it is absent (value
// is all 1's).
// is no need to check the dividing zero, since it is absent (value
// is all 1's).

Dup1, Add, // [bit_mask, pow2(cto) - 1, n, cto]
// 00..001111111111...11 <-- bitmask
// │└─ cto ones ─┘
// └─ additional one

MovUp2, U32and, // [m, pow2(cto) - 1, cto]
// If calcualtion of `cto` is correct, m should be equal to
// If calcualtion of `cto` is correct, m should be equal to
// pow2(cto) - 1

Eq, Assert(0), // [cto, ...]
Expand Down
1 change: 1 addition & 0 deletions miden/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ predicates = "3.0"
test-utils = { package = "miden-test-utils", path = "../test-utils" }
vm-core = { package = "miden-core", path = "../core", version = "0.8" }
winter-fri = { package = "winter-fri", version = "0.8" }
rand_chacha = "0.3.1"
146 changes: 145 additions & 1 deletion miden/tests/integration/operations/decorators/advice.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
use miden_vm::{Digest, Word};
use processor::ExecutionError;
use rand_chacha::rand_core::SeedableRng;

use test_utils::crypto::rpo_falcon512::SecretKey;
use test_utils::rand::rand_array;
use test_utils::serde::Serializable;
use test_utils::{
build_test,
crypto::{MerkleStore, RpoDigest},
rand::rand_value,
Felt,
Felt, TestError,
};

const ADVICE_PUSH_SIG: &str = "
begin
# => [PK, MSG, ...]

# Calling adv.push_sig.rpo_falcon512 on its own gives an error:
# internal error: entered unreachable code: decorators in and empty SPAN block
# add stack calls to avoid this issue.
push.0
drop

adv.push_sig.rpo_falcon512

# => [PK, MSG, ...]
Al-Kindi-0 marked this conversation as resolved.
Show resolved Hide resolved
end";

// ADVICE INJECTION
// ================================================================================================

Expand Down Expand Up @@ -329,3 +351,125 @@ fn advice_insert_hdword() {
let test = build_test!(source, &stack_inputs);
test.expect_stack(&[1, 2, 3, 4, 5, 6, 7, 8]);
}

#[test]
fn advice_push_sig_rpo_falcon_512() {
// Generate random keys and message.
let seed: [u8; 32] = rand_array();
let mut rng = rand_chacha::ChaCha20Rng::from_seed(seed);

let secret_key = SecretKey::with_rng(&mut rng);

// let secret_key = SecretKey::new();
let public_key = secret_key.public_key();
let message: Word = rand_array();

let public_key_word: Word = public_key.into();
let public_key_digest: Digest = public_key_word.into();

// Place digest of the public key and the secret key into advice map as a key value pair.
let secret_key_bytes = secret_key.to_bytes();
let secret_key_adv_map =
secret_key_bytes.iter().map(|a| Felt::new(*a as u64)).collect::<Vec<Felt>>();
let advice_map: Vec<(Digest, Vec<Felt>)> = vec![(public_key_digest, secret_key_adv_map)];

// Lay the public key digest and message into the operation stack.
let mut op_stack = vec![];
let message = message.into_iter().map(|a| a.as_int()).collect::<Vec<u64>>();
op_stack.extend_from_slice(&message);
op_stack.extend_from_slice(
&public_key_digest.as_elements().iter().map(|a| a.as_int()).collect::<Vec<u64>>(),
);
let advice_stack = vec![];

let store = MerkleStore::new();
let mut expected_stack = op_stack.clone();
expected_stack.reverse();

let test =
build_test!(ADVICE_PUSH_SIG, &op_stack, &advice_stack, store, advice_map.into_iter());
test.expect_stack(&expected_stack);
}

#[test]
fn advice_push_sig_rpo_falcon_512_bad_key_value() {
// Generate random keys and message.
let seed: [u8; 32] = rand_array();
let mut rng = rand_chacha::ChaCha20Rng::from_seed(seed);

let secret_key = SecretKey::with_rng(&mut rng);
let public_key = secret_key.public_key();
let message: Word = rand_array();

let public_key_word: Word = public_key.into();
let public_key_digest: Digest = public_key_word.into();

// Place digest of the public key and the secret key into advice map as a key value pair.
let secret_key_bytes = secret_key.to_bytes();
let mut secret_key_adv_map =
secret_key_bytes.iter().map(|a| Felt::new(*a as u64)).collect::<Vec<Felt>>();

// Secret key as bytes must have values in the range 0 - 255.
secret_key_adv_map.pop();
secret_key_adv_map.push(Felt::new(257));

let advice_map: Vec<(Digest, Vec<Felt>)> = vec![(public_key_digest, secret_key_adv_map)];

// Lay the public key digest and message into the operation stack.
let mut op_stack = vec![];
let message = message.into_iter().map(|a| a.as_int()).collect::<Vec<u64>>();
op_stack.extend_from_slice(&message);
op_stack.extend_from_slice(
&public_key_digest.as_elements().iter().map(|a| a.as_int()).collect::<Vec<u64>>(),
);
let advice_stack = vec![];

let store = MerkleStore::new();

let test =
build_test!(ADVICE_PUSH_SIG, &op_stack, &advice_stack, store, advice_map.into_iter());
test.expect_error(TestError::ExecutionError(ExecutionError::MalformedSignatureKey(
"RPO Falcon512",
)));
}

#[test]
fn advice_push_sig_rpo_falcon_512_bad_key_length() {
// Generate random keys and message.
let seed: [u8; 32] = rand_array();
let mut rng = rand_chacha::ChaCha20Rng::from_seed(seed);

let secret_key = SecretKey::with_rng(&mut rng);
let public_key = secret_key.public_key();
let message: Word = rand_array();

let public_key_word: Word = public_key.into();
let public_key_digest: Digest = public_key_word.into();

// Place digest of the public key and the secret key into advice map as a key value pair.
let secret_key_bytes = secret_key.to_bytes();
let mut secret_key_adv_map =
secret_key_bytes.iter().map(|a| Felt::new(*a as u64)).collect::<Vec<Felt>>();

// Secret key as bytes must be at least the correct length.
secret_key_adv_map.pop();
let advice_map: Vec<(Digest, Vec<Felt>)> = vec![(public_key_digest, secret_key_adv_map)];

// Lay the public key digest and message into the operation stack.
let mut op_stack = vec![];
let message = message.into_iter().map(|a| a.as_int()).collect::<Vec<u64>>();
op_stack.extend_from_slice(&message);
op_stack.extend_from_slice(
&public_key_digest.as_elements().iter().map(|a| a.as_int()).collect::<Vec<u64>>(),
);
let advice_stack = vec![];

let store = MerkleStore::new();

let test =
build_test!(ADVICE_PUSH_SIG, &op_stack, &advice_stack, store, advice_map.into_iter());

test.expect_error(TestError::ExecutionError(ExecutionError::MalformedSignatureKey(
"RPO Falcon512",
)));
}
2 changes: 2 additions & 0 deletions stdlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ sha3 = "0.10"
test-utils = { package = "miden-test-utils", path = "../test-utils" }
winter-air = { package = "winter-air", version = "0.8" }
winter-fri = { package = "winter-fri", version = "0.8" }
rand = { version = "0.8.5", default-features = false }
num = "0.4.1"
bobbinth marked this conversation as resolved.
Show resolved Hide resolved

[build-dependencies]
assembly = { package = "miden-assembly", path = "../assembly", version = "0.8" }
18 changes: 10 additions & 8 deletions stdlib/asm/crypto/dsa/rpo_falcon512.masm
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export.hash_to_point.2
# Absorb the message
swapw loc_loadw.1 swapw hperm

# Squeeze the coefficents and save them
# Squeeze the coefficients and save them
repeat.63
swapw dup.12
mem_storew
Expand Down Expand Up @@ -212,7 +212,7 @@ export.load_h_s2_and_product.1
movup.2 assert_eq
assert_eq

# 4) Load s2 (Due to the final norm test we do not need to range check the s2 coefficents)
# 4) Load s2 (Due to the final norm test we do not need to range check the s2 coefficients)
padw padw
repeat.64
adv_pipe hperm
Expand Down Expand Up @@ -242,7 +242,7 @@ end
#! Output: [...]
#!
#! Cycles: 2504
export.probablistic_product.4
export.probabilistic_product.4
# 1) Save the pointers
push.0 movdn.3
loc_storew.0
Expand Down Expand Up @@ -473,7 +473,7 @@ end
#! All of the above implies that we can compute s1_i with only one modular reduction at the end,
#! in addition to one modular reduction applied to c_i.
#! Moreover, since we are only interested in the square norm of s1_i, we do not have to store
#! s1_i and then load it at a later point, and instead we can immediatly follow the computation
#! s1_i and then load it at a later point, and instead we can immediately follow the computation
#! of s1_i with computing its square norm.
#! After computing the square norm of s1_i, we can accumulate into an accumulator to compute the
#! sum of the square norms of all the coefficients of polynomial c. Using the overflow stack, this
Expand Down Expand Up @@ -515,7 +515,7 @@ export.compute_s1_norm_sq
exec.norm_sq
#=> [norm(e)^2, ...]

# Move the result out of the way so that we can process the remaining coefficents
# Move the result out of the way so that we can process the remaining coefficients
movdn.10

# 3) Compute the squared norm of (i + 1)-th coefficient of s1
Expand Down Expand Up @@ -599,16 +599,18 @@ export.verify.1665

# 2) Load the NONCE from the advice provider. This is encoded as 8 field elements
padw adv_loadw padw adv_loadw
#=> [PK, MSG, NONCE1, NONCE0, ...]
#=> [NONCE1, NONCE0, PK, MSG...]

# 3) Load the public key polynomial h and the signature polynomial s2 and the product of
# the two polynomials pi := h * s2 in Z_Q[x]. This also checks that h hashes to the provided
# digest PK. While loading the polynomials, the hash of the three polynomials is computed
# and the first half of the digest is kept on the stack for later use by the
# `probablistic_product` procedure.
# `probabilistic_product` procedure.

swapdw
#=> [PK, MSG, NONCE1, NONCE0...]
locaddr.0
#=> [h_ptr, PK, MSG, NONCE1, NONCE0...]
exec.load_h_s2_and_product
#=> [tau1, tau0, tau_ptr, MSG, NONCE1, NONCE1, ...] (Cycles: 5050)

Expand All @@ -632,7 +634,7 @@ export.verify.1665
locaddr.0 # h ptr
#=> [h_ptr, zeros_ptr, tau_ptr, ...]

exec.probablistic_product
exec.probabilistic_product
#=> [...] (Cycles: 2504)

# 6) Compute the squared norm of s1 := c - h * s2 (in Z_q[x]/(phi))
Expand Down
Loading
Loading