chancehudson / ashlang

Apache License 2.0
6 stars 2 forks source link

feat: print a path of function #49

Closed baumstern closed 1 week ago

baumstern commented 1 week ago

Fixes #46

tasm:

...
call lower32_____s (stdlib/u32/lower32.tasm)
swap 2
pop 1
dup 2
dup 2
call xor_____s_s (stdlib/u32/xor.tasm)
push 7
call shlc_____s_s (stdlib/u32/shlc.tasm)
swap 3
pop 1
dup 3
push 0
...

r1cs:

cargo run --release -- r1cs_readme --target r1cs --include ./test-vectors --include stdlib --print '--scalar field to execute in' foi
   Compiling ashlang v0.1.0 (/Users/daehyun/workspace/ashlang/ashlang)
    Finished `release` profile [optimized] target(s) in 7.49s
     Running `target/release/ashlang r1cs_readme --target r1cs --include ./test-vectors --include stdlib --print '--scalar field to execute in' foi`
x1 = (1*one) * (99*one)                 # scalar literal (99) to signal index 0 (member of vector)
x2 = (1*one) * (43*one)                 # scalar literal (43) to signal index 0 (member of vector)
x3 = (1*x1) * (1*x2)                    # let v
x4 = (1*one) / (1*x2)                   # let v
x5 = (1*x1) * (1*x4)                    # let v
x6 = (1*x3 + 1*x5) * (1*one)            # let v
x7 = (1*x6 + 18446744069414584311*one) * (1*one) # let v
x8 = (9008875010644336127*one) + (0*one) # assert_eq() (stdlib/assert_eq.ar1cs)
x9 = (1*x7) * (1*x7)                    # let v2
x10 = (1*x9) * (1*x9)                   # let v4
x11 = (1*x10) * (1*x7)                  # return call in pow5() (stdlib/pow5.ash)
x12 = (1*x7) * (1*x7)                   # return call in pow5() (stdlib/pow5.ash)
x13 = (1*x12) * (1*x7)                  # return call in pow5() (stdlib/pow5.ash)
x14 = (1*x13) * (1*x7)                  # return call in pow5() (stdlib/pow5.ash)
x15 = (1*x14) * (1*x7)                  # return call in pow5() (stdlib/pow5.ash)
x16 = (1*one) * (21941893*one)          # scalar literal (00000000000021941893) to signal index 0 (member of vector)
x17 = (2*one) radix (1*x16)             # b is the square root of a
x18 = (899715509682497048*one) + (0*one) # assert_eq() (stdlib/assert_eq.ar1cs)
x19 = (1*x17) * (1*x17)                 # assert_eq() (stdlib/assert_eq.ar1cs)
x20 = (0*one + 18446744069414584320*x17) * (1*one) # let high_root
x21 = (17547028559732087273*one) + (0*one) # assert_eq() (stdlib/assert_eq.ar1cs)
x22 = (1*x20) * (1*x20)                 # assert_eq() (stdlib/assert_eq.ar1cs)
x23 = (0*one + 18446744069414584320*x16) * (1*one) # assert_eq() (stdlib/assert_eq.ar1cs)
x24 = (1*x17) * (1*x20)                 # assert_eq() (stdlib/assert_eq.ar1cs)
0 = (18446744069414584320*one) * (18446744069414584320*one) - (1*one) # field safety constraint
0 = (1*x1) * (1*one) - (99*one)         # scalar literal (99) to signal index (0) (member of vector)
0 = (1*x2) * (1*one) - (43*one)         # scalar literal (43) to signal index (0) (member of vector)
0 = (1*x1) * (1*x2) - (1*x3)            # multiplication between 1 and 2 into 3
0 = (1*x2) * (1*x4) - (1*one)           # inversion of 2 into 4 (1/2)
0 = (1*x1) * (1*x4) - (1*x5)            # multiplication of 1 and 4 into 5 (2/2)
0 = (1*x3 + 1*x5) * (1*one) - (1*x6)    # addition between 3 and 5 into 6
0 = (10*one + 1*x7) * (1*one) - (1*x6)  # subtraction between 6 and (10) into 7
0 = (1*x8) * (1*one) - (9008875010644336127*one) # assigning literal (09008875010644336127) to signal 8
0 = (1*x7 + 0*one) * (1*one) - (1*x8)   # assert equality
0 = (1*x7) * (1*x7) - (1*x9)            # multiplication between 7 and 7 into 9
0 = (1*x9) * (1*x9) - (1*x10)           # multiplication between 9 and 9 into 10
0 = (1*x10) * (1*x7) - (1*x11)          # multiplication between 10 and 7 into 11
0 = (1*x7) * (1*x7) - (1*x12)           # multiplication between 7 and 7 into 12
0 = (1*x12) * (1*x7) - (1*x13)          # multiplication between 12 and 7 into 13
0 = (1*x13) * (1*x7) - (1*x14)          # multiplication between 13 and 7 into 14
0 = (1*x14) * (1*x7) - (1*x15)          # multiplication between 14 and 7 into 15
0 = (1*x11 + 0*one) * (1*one) - (1*x15) # assert equality
0 = (1*x16) * (1*one) - (21941893*one)  # scalar literal (00000000000021941893) to signal index (0) (member of vector)
0 = (1*x17) * (1*x17) - (1*x16)         # assert that a = b*b
0 = (1*x18) * (1*one) - (899715509682497048*one) # assigning literal (00899715509682497048) to signal 18
0 = (1*x17 + 0*one) * (1*one) - (1*x18) # assert equality
0 = (1*x17) * (1*x17) - (1*x19)         # multiplication between 17 and 17 into 19
0 = (1*x16 + 0*one) * (1*one) - (1*x19) # assert equality
0 = (1*x17 + 1*x20) * (1*one) - (0*one) # subtraction between (0) and 17 into 20
0 = (1*x21) * (1*one) - (17547028559732087273*one) # assigning literal (17547028559732087273) to signal 21
0 = (1*x20 + 0*one) * (1*one) - (1*x21) # assert equality
0 = (1*x20) * (1*x20) - (1*x22)         # multiplication between 20 and 20 into 22
0 = (1*x16 + 0*one) * (1*one) - (1*x22) # assert equality
0 = (1*x16 + 1*x23) * (1*one) - (0*one) # subtraction between (0) and 16 into 23
0 = (1*x17) * (1*x20) - (1*x24)         # multiplication between 17 and 20 into 24
0 = (1*x23 + 0*one) * (1*one) - (1*x24) # assert equality

R1CS: built and validated witness ✅
No outputs were generated
chancehudson commented 1 week ago

Oh one other thing, try not to force push the branch too much. It's good to be able to review the change history in a pr. I'll force push a branch to correct an error, or if the linter is failing or something like that, but otherwise I try to leave the history as is. We'll squash the commits together during merge anyway.