Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Hakkush-07
Copy link
Collaborator

@Hakkush-07 Hakkush-07 commented Oct 4, 2024

This PR optimizes u32_add_carry from 145 to 90 bytes, and u32_add_nocarry from 95 to 80 bytes.

The explanation:

a_div, a_rem = u32_inflate_unsigned(a)
$a_\text{div} = $
$\qquad 0$ if $0 \leq a_\text{u32} \leq 2^{31}-1$,
$\qquad 1$ if $2^{31} \leq a_\text{u32} \leq 2^{32}-1$
$a_\text{rem} = $
$\qquad a_\text{u32}$ if $0 \leq a_\text{u32} \leq 2^{31}-1$
$\qquad a_\text{u32}-2^{31}$ if $2^{31} \leq a_\text{u32} \leq 2^{32}-1$

b_div', b_rem' = u32_inflate_signed(b)
$b_\text{div}' =$
$\qquad 0$ if $2^{31}+1 \leq b_\text{u32} \leq 2^{32}-1$ or $b=0$,
$\qquad 1$ if $1 \leq b_\text{u32} \leq 2^{31}$
$b_\text{rem}' = $
$\qquad b_\text{u32}-2^{32}$ if $2^{31}+1 \leq b_\text{u32} \leq 2^{32}-1$,
$\qquad 0$ if $b=0$,
$\qquad b_\text{u32}-2^{31}$ if $1 \leq b_\text{u32} \leq 2^{31}$

$c=a_\text{rem} + b_\text{rem}'$

If $(a_\text{div},b_\text{div}')=(1,0)$ or $(0,1)$, then carry occurs when $a_\text{div}=1$ and $b\neq 0$. Sum is $c-2^{31}$ if $c>0$, and else $c+2^{31}$
If $(a_\text{div},b_\text{div}')=(0,0)$, then carry occurs when $c\geq 0$ and $b\neq 0$. Sum is $c$
If $(a_\text{div},b_\text{div}')=(1,1)$, then carry occurs when $c\geq 0$. Sum is $c$

@stillsaiko stillsaiko merged commit 8f9599f into BitVM:main Oct 4, 2024
@Hakkush-07 Hakkush-07 deleted the u32-add branch October 15, 2024 11:17
justin-elementlabs added a commit to elementlabs42/BitVM that referenced this pull request Nov 27, 2024
* Add basic implementation for `check_hash_sig`

* Add separate function for `blake3_160_var_length`

* Add separate function for `sign_hash`

* Complete version of algorithm 9 in On Proving Pairings (BitVM#83)

* resolve build error

* keep local ell_coeffs consistant with remote ark_ec, and move double/add into utils

* two things left: backward compatibility need to be done for arkworks, mul_by_034_with_4_constant_affine need to filled

* fill mul_by_34 instead of mul_by_034_with_4_constant_affine

* add test for fq12_mul_by_34, and some comment for fq12_mu_by_034_with_4_constant

* fix bug for fq12_mul_by_34

* fix bug on from_eval_point

* up

* test for from_eval_point, passed

* update package url for bn254

* add test_ell_by_constant_affine

* test of dual pairing passed!

* remove bn254_ell

* modify tests

* frame of quad_pairing

* refactor: remove unnecessary for loop

* fill utility funcs for quad_pairing

* fix conflicts

* restore

* fix double error

* text: add comments

* add test

* test: update test to use negative value for bias

* text: add comment

* test: add test for affine_double_line

* test: add check test for line type

* refactor: sync with upstream to use new form of script

* refactor: support new form of script for miller loop  in affine space

* refactor: add test for affine space

* fix: use projective mode to fix test error

* test: add test for quad pairing

* test: handle tangent line check logic

* update test

* add debug info

* debug

* debug

* change to use vec for computation

* refactor

* fixed version

* fix frob square bug

* code refactoring

* text: add comment for code

* feat: add pairing verification function

* comment for stack

* f initial value is c inverse

* update f with multiplying c or c inverse

* update comment

* update stack index

* update f

* update comment

* add test

* update test

* text: add comment

* fix index for roll to calculate Frobenius map

* refactor: update stack index

* update comment

* update comment

* update f value at first

* update comment

* fix stack index

* update comment

* add log

* update comment

* update comment

* fix: square f all the time

* this log will cause error, delete it

* update pairing, only use affine mode

* update test to support affine mode

* update test to support affine space for pairing zero test

* update test for miller loop in projective space

* feat: make fflonk verifier support dual pairing in affine space

* get groth16 verifier optimized with affine mode done

* code clean

---------

Co-authored-by: Harry <[email protected]>

* Use `run` function in Winternitz tests

* Add bridge progress (BitVM#79)

* 👩‍🏫 Reorganize bridge modules

* 🤓 Stub out more of implementation components

* Fix compilation error

* remove invalid secret and use existing unspendable pubkey

* 🫣 Progress

* 🏏 Fix errors, create alts

* 🎱 Cargo fix

* ✊ Progress

* 👐 Cargo fix

* 🏅 Post meeting

* 😻 Complete txns

* 😼 Work of refactoring

* 📦 Cargo fix

* 😵 Progress

* 😐 Progress

* 📦 Cargo fix

* 🚀 Progress

* 🤓 Progress

* 👨‍🚀 Progress

* ✂️ Cargo clippy

* 🥍 rustfmt

* 🐙 Progress

* 👨‍🍳 rustfmt

* 👩‍⚖️ Progress

* 🔥 Fix output amounts

* 🧼 Fix op code

* 🤡 fmt

* ❓ Added questions

* Add `peg_in_confirm` and `peg_in_refund` tests

* finish assert tx and add unit test

* fixed bugs and added test cases to disprove tx and burn tx

* fix control block error

* peg in confirm & test

* Refactor `Input` into a struct

* 😼 Fix pub key error by adding new Bitcoin PubKey

* pub key compressed or uncompressed error

* fixed burn tx test case for timelock and added more test cases

* take1 timelock fix & unit test

* clean up

* fixed import

* `peg_in_refund` and `connector_a` fixes

* Add `challenge` tx test

* 🤕 Refactor context

* 🫣 Fix

* 🧼 Fix formatting

* Fix formatting

* Add todo

* Fix function call

* Fix type

* Fix formatting

* Update unspendable

* Format

* Fix burn

* move tests in tests folder

* prettier

* Fixed compilation errors and moved test cases to tests/

* refactoring

* refactoring connector b

* Update messages

* Rust fmt

* Refactor connectors

* Format

* Start updating tests

* Extract network setting from lower level functions

* continue refactoring

* Reorder network param

* Fix tests

* Refactor tests

* Fix formatting

* Format tests

* Fix up a few items

* Implement trait for connectors

* Always use the network provided in context

* Finalize the kick-off tx

* fixed compilation erros

* fix lint

* refactoring tests

* fix lint

* Rename variables

* COmment out incomplete signing code

* Refactor signing

* Restructure components into transactions and connectors

* Rename p2wpkh

* Format

* Replace connector 2 pub key with operator pub key

* Fixes (#23)

* Add codeowners (#24)

* Txn Serialization (#11)

* Fix compilation errors and run rustfmt

* add serialization trait

* add test

* use serde

* remove old version

* eleminate merge differences

* derive serialization for all txns

* Format

* Reorder imports

* feat: use consensus encode

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: stardustPandora <[email protected]>

* [WIP] Refactor pre-signing functions (#22)

* Refactor pre-signing functions

* Refactor remaining transactions

* Refactor

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Refactor contexts

* Refactor signing flow

* Fix some compile time issues

* Fix mutable borrow

* Update test setup

* Finish fixing all compile errors

* Refactor contexts (#26)

* Refactor contexts

* Refactor signing flow

* Fix some compile time issues

* Fix mutable borrow

* Update test setup

* Finish fixing all compile errors

* Rename assert leaf to disprove leaf

* Add integration tests (#21)

* Add peg-in integration tests

* Adjust peg-in integration tests

* Fix `add_input_output()` in disprove tx

* Remove input placeholder from challenge tx

* Add kick_off test and integration tests for challenge and disprove

* Add `take1` and `take2` tests

* Refactor tests and adding outputs

* Allow multiple inputs and one output in `challenge` tx

* Refactor adding inputs and output to `challenge` tx

* Refactor integration challenge test to use `add_inputs_and_output()` function

* Allow adding inputs only once in `challenge` tx (#28)

* Allow adding inputs only once in `challenge` tx

* Fix error msg

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Start on graphs (#27)

* Start on graphs

* Refactor into graph structs

* Commit pseudocode

* Fix compile errors

* Remove graph file

* Fix more warnings work on client

* Rc create graph client (#30)

* Commit progress

* Commit progress

* Start on client (#31)

* Commit progress

* Commit progress

* Merge and fix compile errors

* Update code to be compatible with Script changes

* Small changes to client

* [WIP] Rc create graph - implementation (#29)

* Start on graphs

* Refactor into graph structs

* Commit pseudocode

* Fix compile errors

* Remove graph file

* Fix more warnings work on client

* Fix tests

* Add constants file

* Implement `burn` in `peg_out` graph

* Implement `peg_out` graph remaining txs

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Add serialization and deserialization to graphs

* Refactor tests to use helper outpoint method (#32)

* Remove unused variables

* Add peg-in statuses and peg-out statuses (#34)

* Work on client syncing (#33)

* Refactor serialization

* Work on integrating Amazon S3

* Finished AWS reading and writing

* Make AWS s3 optional

* Fix test

* Update error handling

* Update warning message

* Delete obsolete files

* Refactor and clean up unused variables

* Remove unused variables

* Try to implement formatter for statuses (#35)

* Try to implement formatter for statuses

* Fix result error

* Remove status

* Delete codeowners

---------

Co-authored-by: aristotleee <[email protected]>
Co-authored-by: StarDumpling <[email protected]>
Co-authored-by: timesaved12345 <[email protected]>
Co-authored-by: mac user <[email protected]>
Co-authored-by: franklynot <[email protected]>
Co-authored-by: stardustPandora <[email protected]>

* First prototype chunking for mul and fflonk

* Rework execute_as_chunks to copy over stack

* Executing chunks now copies over stack; add tests

* Remove dependency on seckey in Winternitz sig verification

* Fix: Remove outdated script chunk execution

* Split up if

* Add some debug info in tests

* Quick fix for if in add()

* Quick fix for double

* Use nested script in restart_if

* Print info to file and set target and tolerance

* Update gitignore and Cargo.toml

* Add from_bytes for U254

* Small cleanup and fixes

* Replace restart_if with selector pattern

* Fix: Unresolved restart_if import

* Optimized Fq multiplication using hints with w-width windowed method (BitVM#87)

* optimized tunable field multiplication using w-width windowed method

* reverted back formatting changes, and added few docstrings

* align comments

* fix: fq-mul (BitVM#86)

* fix is_positive()

* fix N_WINDOW

* better limb_add_with_carry_prevent_overflow and limb_double_with_carry_prevent_overflow

* feat: hinted mul integration

* G1 scalar mul optimization (BitVM#88)

* perf: g1_scalar_mul optimization

* add a few comments to G1.scalar_mul

---------

Co-authored-by: fatih <[email protected]>

* Fq.hinted_square

* Fq2.hinted_square

* feat: hinted mul by const

* Fq6.hinted_square

* feat: fq2 hinted mul by const

* Fq12.hinted_square

* feat: hinted line utils

* hinted_frobenius functions

* G1Projective.hinted_double

* feat: hinted g1 projective add

* Upgrade to v3 graph, add musig2 signing, improve client (BitVM#91)

* 👩‍🏫 Reorganize bridge modules

* 🤓 Stub out more of implementation components

* Fix compilation error

* remove invalid secret and use existing unspendable pubkey

* 🫣 Progress

* 🏏 Fix errors, create alts

* 🎱 Cargo fix

* ✊ Progress

* 👐 Cargo fix

* 🏅 Post meeting

* 😻 Complete txns

* 😼 Work of refactoring

* 📦 Cargo fix

* 😵 Progress

* 😐 Progress

* 📦 Cargo fix

* 🚀 Progress

* 🤓 Progress

* 👨‍🚀 Progress

* ✂️ Cargo clippy

* 🥍 rustfmt

* 🐙 Progress

* 👨‍🍳 rustfmt

* 👩‍⚖️ Progress

* 🔥 Fix output amounts

* 🧼 Fix op code

* 🤡 fmt

* ❓ Added questions

* Add `peg_in_confirm` and `peg_in_refund` tests

* finish assert tx and add unit test

* fixed bugs and added test cases to disprove tx and burn tx

* fix control block error

* peg in confirm & test

* Refactor `Input` into a struct

* 😼 Fix pub key error by adding new Bitcoin PubKey

* pub key compressed or uncompressed error

* fixed burn tx test case for timelock and added more test cases

* take1 timelock fix & unit test

* clean up

* fixed import

* `peg_in_refund` and `connector_a` fixes

* Add `challenge` tx test

* 🤕 Refactor context

* 🫣 Fix

* 🧼 Fix formatting

* Fix formatting

* Add todo

* Fix function call

* Fix type

* Fix formatting

* Update unspendable

* Format

* Fix burn

* move tests in tests folder

* prettier

* Fixed compilation errors and moved test cases to tests/

* refactoring

* refactoring connector b

* Update messages

* Rust fmt

* Refactor connectors

* Format

* Start updating tests

* Extract network setting from lower level functions

* continue refactoring

* Reorder network param

* Fix tests

* Refactor tests

* Fix formatting

* Format tests

* Fix up a few items

* Implement trait for connectors

* Always use the network provided in context

* Finalize the kick-off tx

* fixed compilation erros

* fix lint

* refactoring tests

* fix lint

* Rename variables

* COmment out incomplete signing code

* Refactor signing

* Restructure components into transactions and connectors

* Rename p2wpkh

* Format

* Replace connector 2 pub key with operator pub key

* Fixes (#23)

* Add codeowners (#24)

* Txn Serialization (#11)

* Fix compilation errors and run rustfmt

* add serialization trait

* add test

* use serde

* remove old version

* eleminate merge differences

* derive serialization for all txns

* Format

* Reorder imports

* feat: use consensus encode

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: stardustPandora <[email protected]>

* [WIP] Refactor pre-signing functions (#22)

* Refactor pre-signing functions

* Refactor remaining transactions

* Refactor

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Refactor contexts

* Refactor signing flow

* Fix some compile time issues

* Fix mutable borrow

* Update test setup

* Finish fixing all compile errors

* Refactor contexts (#26)

* Refactor contexts

* Refactor signing flow

* Fix some compile time issues

* Fix mutable borrow

* Update test setup

* Finish fixing all compile errors

* Rename assert leaf to disprove leaf

* Add integration tests (#21)

* Add peg-in integration tests

* Adjust peg-in integration tests

* Fix `add_input_output()` in disprove tx

* Remove input placeholder from challenge tx

* Add kick_off test and integration tests for challenge and disprove

* Add `take1` and `take2` tests

* Refactor tests and adding outputs

* Allow multiple inputs and one output in `challenge` tx

* Refactor adding inputs and output to `challenge` tx

* Refactor integration challenge test to use `add_inputs_and_output()` function

* Allow adding inputs only once in `challenge` tx (#28)

* Allow adding inputs only once in `challenge` tx

* Fix error msg

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Start on graphs (#27)

* Start on graphs

* Refactor into graph structs

* Commit pseudocode

* Fix compile errors

* Remove graph file

* Fix more warnings work on client

* Rc create graph client (#30)

* Commit progress

* Commit progress

* Start on client (#31)

* Commit progress

* Commit progress

* Merge and fix compile errors

* Update code to be compatible with Script changes

* Small changes to client

* [WIP] Rc create graph - implementation (#29)

* Start on graphs

* Refactor into graph structs

* Commit pseudocode

* Fix compile errors

* Remove graph file

* Fix more warnings work on client

* Fix tests

* Add constants file

* Implement `burn` in `peg_out` graph

* Implement `peg_out` graph remaining txs

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Add serialization and deserialization to graphs

* Refactor tests to use helper outpoint method (#32)

* Remove unused variables

* Add peg-in statuses and peg-out statuses (#34)

* Work on client syncing (#33)

* Refactor serialization

* Work on integrating Amazon S3

* Finished AWS reading and writing

* Make AWS s3 optional

* Fix test

* Update error handling

* Update warning message

* Delete obsolete files

* Refactor and clean up unused variables

* Remove unused variables

* Try to implement formatter for statuses (#35)

* Try to implement formatter for statuses

* Fix result error

* Remove status

* Delete codeowners

* Add peg out graph methods to client

* Implement `peg-in` graph tx functions (#36)

* Implement `peg-in` graph tx functions

* Use timelock constants

* Verify funding inputs at the beginnin of every integration test (#38)

* Add human-readable statuses (#39)

* Add human-readable statuses

* Rephrase statuses

* feat: refine evm address encode (#40)

Co-authored-by: stardustPandora <[email protected]>

* Add merge + validation POC (#37)

* Add merge POC

* Work on validation

* Add graph validation

* Format

* Add todo comment

* Add todo comment

* `read()`, `save()` and `merge()` implementation

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: StarDumpling <[email protected]>

* Add ftp and ftps support (#42)

* Add merge POC

* Work on validation

* Add graph validation

* Format

* Add todo comment

* Add todo comment

* Work on adding ftp and ftps

* Fix compilation issues

* Clean up cargo deps

* Add sftp (#44)

* Add sftp support

* Fully integrate sftp

---------

Co-authored-by: ivebeenherebefore <[email protected]>

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Add debug message to transaction verification

* Ftp tests (#45)

* Add progress

* Continue debugging

* Fix ftp lib

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Peg out test (#43)

* add peg out test

* updated with inscription

* use bitcoin hash

* format

* Add `validate()` test cases (#47)

* Add `merge()` test cases (#48)

* Add ftp tests (#52)

* Add progress

* Continue debugging

* Fix ftp lib

* Try russh

* Rollback russh

* Disable ftp datastores for now

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* update test values (#53)

* add evm address for depositor (#54)

* Add MuSig2 (#41)

* Add merge POC

* Work on validation

* Add graph validation

* Format

* Add todo comment

* Add todo comment

* Add MuSig2 nonce handling

* Move nonce handling down to transaction layer, use common key types

* Add partial signatures, refactor

* Add a MuSig2 E2E test

* Update tests after `setup_test()` change

* Add signer key generation sample

* Add n-of-n pubkey generation

* Flesh out the MuSig2 test

* Refactor the client

* Refactor

* Pass the list of keys by reference in the client 'constructor'

* Add a TODO

* Clean up

* Clean up

* Refactored Musig2 (#46)

* Work on refactor

* Update N of N generation

* Work on refactor

* Work on applying nonce and signatures to other txns

* Commit changes

* Finish refactor and clean up

* Fix tests

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Refactor

* Lint

* Merge musig2 nonces and signatures, save local files to folders

* Save private nonces to local file

* Update some method names

* Wrap musig2 signature into taproot signature

* Change n of n p2wsh to p2tr (#50)

* Change n of n p2wsh to p2tr

* Fix consensus hex

* Fix leaf index

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Wait for peg-in deposit tx to be mined in musig2 test

* Fix merge

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: justin-elementlabs <[email protected]>
Co-authored-by: StarDumpling <[email protected]>

* Add client peg-out tests (#57)

* Refactor num blocks per x weeks constant

* Add client peg-out tests

* Read private data from local file (#56)

* Reduce console verbosity + reword messages for clarity

* Read private data from local file

* Remove unused function

---------

Co-authored-by: StarDumpling <[email protected]>

* Add directories to data stores, add `destination_network` (#60)

* Add public nonce verification (#63)

* Add nonce signatures

* OsRng is safe to use

* Do not fetch data when instantiating the `BitVMClient`

* Add pub nonce verification

* Rename test file `musig2.rs` to `musig2_peg_in.rs` for consistency

* Do not fail fast on pubnonce verification (get all the failures before returning)

* Send error messages to the error output

* L2 chain adaptors (#58)

* add l2 chain adaptors

* Fix compilation error

* debug pegin events

* feat: add pegin event

* type fixes in peg in event

* fix u256 to amount cast

* add peg out burnt event

* checks length of results

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: stardustPandora <[email protected]>

* Graph v3 merged (#59)

* Add merge POC

* Work on validation

* Add graph validation

* Format

* Add todo comment

* Add todo comment

* Add MuSig2 nonce handling

* Move nonce handling down to transaction layer, use common key types

* Add partial signatures, refactor

* Add a MuSig2 E2E test

* Update tests after `setup_test()` change

* Add signer key generation sample

* Add n-of-n pubkey generation

* Flesh out the MuSig2 test

* Refactor the client

* Refactor

* Pass the list of keys by reference in the client 'constructor'

* Add a TODO

* Clean up

* Clean up

* Refactored Musig2 (#46)

* Work on refactor

* Update N of N generation

* Work on refactor

* Work on applying nonce and signatures to other txns

* Commit changes

* Finish refactor and clean up

* Fix tests

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Refactor

* Lint

* Merge musig2 nonces and signatures, save local files to folders

* Save private nonces to local file

* Update some method names

* Wrap musig2 signature into taproot signature

* Change n of n p2wsh to p2tr (#50)

* Change n of n p2wsh to p2tr

* Fix consensus hex

* Fix leaf index

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Start v3 graph

* Work on graph v3

* Work on changing connectors and rename _d

* Rename leafs

* Work on transactions

* Finish updating txns to v3 graph

* Remove comment

* Refactor inputs

* Update graphs

* Update status check

* Update peg out graph

* Start updating status

* Graph v3 status progress

* Finish peg out status update

* Update tests

* Remove lib

* Fix integration tests

* Refactor

* Revert unneeded changes

* Update musig tests

* Update musig2 peg out tests

* Fix issues

* Fix merging

* Fix compile errors

* Fixes

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: franklynot <[email protected]>
Co-authored-by: StarDumpling <[email protected]>

* Nonce signature tests (#67)

* Add nonce signatures

* OsRng is safe to use

* Do not fetch data when instantiating the `BitVMClient`

* Add pub nonce verification

* Rename test file `musig2.rs` to `musig2_peg_in.rs` for consistency

* Do not fail fast on pubnonce verification (get all the failures before returning)

* Send error messages to the error output

* Add UTs for `verify_public_nonces()`

* Refactor test

* Fixes after the merge

* One more fix after the merge

* Reduce compiler warnings

* Undo the last change in files unrelated to this PR

* Sync with BitVM codebase (#70)

* Add basic implementation for `check_hash_sig`

* Add separate function for `blake3_160_var_length`

* Add separate function for `sign_hash`

* Complete version of algorithm 9 in On Proving Pairings (BitVM#83)

* resolve build error

* keep local ell_coeffs consistant with remote ark_ec, and move double/add into utils

* two things left: backward compatibility need to be done for arkworks, mul_by_034_with_4_constant_affine need to filled

* fill mul_by_34 instead of mul_by_034_with_4_constant_affine

* add test for fq12_mul_by_34, and some comment for fq12_mu_by_034_with_4_constant

* fix bug for fq12_mul_by_34

* fix bug on from_eval_point

* up

* test for from_eval_point, passed

* update package url for bn254

* add test_ell_by_constant_affine

* test of dual pairing passed!

* remove bn254_ell

* modify tests

* frame of quad_pairing

* refactor: remove unnecessary for loop

* fill utility funcs for quad_pairing

* fix conflicts

* restore

* fix double error

* text: add comments

* add test

* test: update test to use negative value for bias

* text: add comment

* test: add test for affine_double_line

* test: add check test for line type

* refactor: sync with upstream to use new form of script

* refactor: support new form of script for miller loop  in affine space

* refactor: add test for affine space

* fix: use projective mode to fix test error

* test: add test for quad pairing

* test: handle tangent line check logic

* update test

* add debug info

* debug

* debug

* change to use vec for computation

* refactor

* fixed version

* fix frob square bug

* code refactoring

* text: add comment for code

* feat: add pairing verification function

* comment for stack

* f initial value is c inverse

* update f with multiplying c or c inverse

* update comment

* update stack index

* update f

* update comment

* add test

* update test

* text: add comment

* fix index for roll to calculate Frobenius map

* refactor: update stack index

* update comment

* update comment

* update f value at first

* update comment

* fix stack index

* update comment

* add log

* update comment

* update comment

* fix: square f all the time

* this log will cause error, delete it

* update pairing, only use affine mode

* update test to support affine mode

* update test to support affine space for pairing zero test

* update test for miller loop in projective space

* feat: make fflonk verifier support dual pairing in affine space

* get groth16 verifier optimized with affine mode done

* code clean

---------

Co-authored-by: Harry <[email protected]>

* Use `run` function in Winternitz tests

* Add bridge progress (BitVM#79)

* 👩‍🏫 Reorganize bridge modules

* 🤓 Stub out more of implementation components

* Fix compilation error

* remove invalid secret and use existing unspendable pubkey

* 🫣 Progress

* 🏏 Fix errors, create alts

* 🎱 Cargo fix

* ✊ Progress

* 👐 Cargo fix

* 🏅 Post meeting

* 😻 Complete txns

* 😼 Work of refactoring

* 📦 Cargo fix

* 😵 Progress

* 😐 Progress

* 📦 Cargo fix

* 🚀 Progress

* 🤓 Progress

* 👨‍🚀 Progress

* ✂️ Cargo clippy

* 🥍 rustfmt

* 🐙 Progress

* 👨‍🍳 rustfmt

* 👩‍⚖️ Progress

* 🔥 Fix output amounts

* 🧼 Fix op code

* 🤡 fmt

* ❓ Added questions

* Add `peg_in_confirm` and `peg_in_refund` tests

* finish assert tx and add unit test

* fixed bugs and added test cases to disprove tx and burn tx

* fix control block error

* peg in confirm & test

* Refactor `Input` into a struct

* 😼 Fix pub key error by adding new Bitcoin PubKey

* pub key compressed or uncompressed error

* fixed burn tx test case for timelock and added more test cases

* take1 timelock fix & unit test

* clean up

* fixed import

* `peg_in_refund` and `connector_a` fixes

* Add `challenge` tx test

* 🤕 Refactor context

* 🫣 Fix

* 🧼 Fix formatting

* Fix formatting

* Add todo

* Fix function call

* Fix type

* Fix formatting

* Update unspendable

* Format

* Fix burn

* move tests in tests folder

* prettier

* Fixed compilation errors and moved test cases to tests/

* refactoring

* refactoring connector b

* Update messages

* Rust fmt

* Refactor connectors

* Format

* Start updating tests

* Extract network setting from lower level functions

* continue refactoring

* Reorder network param

* Fix tests

* Refactor tests

* Fix formatting

* Format tests

* Fix up a few items

* Implement trait for connectors

* Always use the network provided in context

* Finalize the kick-off tx

* fixed compilation erros

* fix lint

* refactoring tests

* fix lint

* Rename variables

* COmment out incomplete signing code

* Refactor signing

* Restructure components into transactions and connectors

* Rename p2wpkh

* Format

* Replace connector 2 pub key with operator pub key

* Fixes (#23)

* Add codeowners (#24)

* Txn Serialization (#11)

* Fix compilation errors and run rustfmt

* add serialization trait

* add test

* use serde

* remove old version

* eleminate merge differences

* derive serialization for all txns

* Format

* Reorder imports

* feat: use consensus encode

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: stardustPandora <[email protected]>

* [WIP] Refactor pre-signing functions (#22)

* Refactor pre-signing functions

* Refactor remaining transactions

* Refactor

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Refactor contexts

* Refactor signing flow

* Fix some compile time issues

* Fix mutable borrow

* Update test setup

* Finish fixing all compile errors

* Refactor contexts (#26)

* Refactor contexts

* Refactor signing flow

* Fix some compile time issues

* Fix mutable borrow

* Update test setup

* Finish fixing all compile errors

* Rename assert leaf to disprove leaf

* Add integration tests (#21)

* Add peg-in integration tests

* Adjust peg-in integration tests

* Fix `add_input_output()` in disprove tx

* Remove input placeholder from challenge tx

* Add kick_off test and integration tests for challenge and disprove

* Add `take1` and `take2` tests

* Refactor tests and adding outputs

* Allow multiple inputs and one output in `challenge` tx

* Refactor adding inputs and output to `challenge` tx

* Refactor integration challenge test to use `add_inputs_and_output()` function

* Allow adding inputs only once in `challenge` tx (#28)

* Allow adding inputs only once in `challenge` tx

* Fix error msg

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Start on graphs (#27)

* Start on graphs

* Refactor into graph structs

* Commit pseudocode

* Fix compile errors

* Remove graph file

* Fix more warnings work on client

* Rc create graph client (#30)

* Commit progress

* Commit progress

* Start on client (#31)

* Commit progress

* Commit progress

* Merge and fix compile errors

* Update code to be compatible with Script changes

* Small changes to client

* [WIP] Rc create graph - implementation (#29)

* Start on graphs

* Refactor into graph structs

* Commit pseudocode

* Fix compile errors

* Remove graph file

* Fix more warnings work on client

* Fix tests

* Add constants file

* Implement `burn` in `peg_out` graph

* Implement `peg_out` graph remaining txs

---------

Co-authored-by: ivebeenherebefore <[email protected]>

* Add serialization and deserialization to graphs

* Refactor tests to use helper outpoint method (#32)

* Remove unused variables

* Add peg-in statuses and peg-out statuses (#34)

* Work on client syncing (#33)

* Refactor serialization

* Work on integrating Amazon S3

* Finished AWS reading and writing

* Make AWS s3 optional

* Fix test

* Update error handling

* Update warning message

* Delete obsolete files

* Refactor and clean up unused variables

* Remove unused variables

* Try to implement formatter for statuses (#35)

* Try to implement formatter for statuses

* Fix result error

* Remove status

* Delete codeowners

---------

Co-authored-by: aristotleee <[email protected]>
Co-authored-by: StarDumpling <[email protected]>
Co-authored-by: timesaved12345 <[email protected]>
Co-authored-by: mac user <[email protected]>
Co-authored-by: franklynot <[email protected]>
Co-authored-by: stardustPandora <[email protected]>

* First prototype chunking for mul and fflonk

* Rework execute_as_chunks to copy over stack

* Executing chunks now copies over stack; add tests

* Remove dependency on seckey in Winternitz sig verification

* Fix: Remove outdated script chunk execution

* Split up if

* Add some debug info in tests

* Quick fix for if in add()

* Quick fix for double

* Use nested script in restart_if

* Print info to file and set target and tolerance

* Update gitignore and Cargo.toml

* Add from_bytes for U254

* Small cleanup and fixes

* Replace restart_if with selector pattern

* Fix: Unresolved restart_if import

* Optimized Fq multiplication using hints with w-width windowed method (BitVM#87)

* optimized tunable field multiplication using w-width windowed method

* reverted back formatting changes, and added few docstrings

* align comments

* fix: fq-mul (BitVM#86)

* G1 scalar mul optimization (BitVM#88)

* perf: g1_scalar_mul optimization

* add a few comments to G1.scalar_mul

---------

Co-authored-by: fatih <[email protected]>

---------

Co-authored-by: robinlinus <[email protected]>
Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: PayneJoe <[email protected]>
Co-authored-by: Harry <[email protected]>
Co-authored-by: aristotleee <[email protected]>
Co-authored-by: StarDumpling <[email protected]>
Co-authored-by: timesaved12345 <[email protected]>
Co-authored-by: mac user <[email protected]>
Co-authored-by: franklynot <[email protected]>
Co-authored-by: stardustPandora <[email protected]>
Co-authored-by: Lukas <[email protected]>
Co-authored-by: bbist <[email protected]>
Co-authored-by: FatihSolak <[email protected]>
Co-authored-by: Hakan Karakuş <[email protected]>
Co-authored-by: fatih <[email protected]>

---------

Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: aristotleee <[email protected]>
Co-authored-by: StarDumpling <[email protected]>
Co-authored-by: timesaved12345 <[email protected]>
Co-authored-by: mac user <[email protected]>
Co-authored-by: franklynot <[email protected]>
Co-authored-by: stardustPandora <[email protected]>
Co-authored-by: stardustPandora <[email protected]>
Co-authored-by: robinlinus <[email protected]>
Co-authored-by: PayneJoe <[email protected]>
Co-authored-by: Harry <[email protected]>
Co-authored-by: Lukas <[email protected]>
Co-authored-by: bbist <[email protected]>
Co-authored-by: FatihSolak <[email protected]>
Co-authored-by: Hakan Karakuş <[email protected]>
Co-authored-by: fatih <[email protected]>

* add Fq::mul_bucket and Fq::mul_by_constant_bucket (BitVM#89)

Co-authored-by: aiden-bitcoin <[email protected]>

* feat: hinted scalar mul by const g1

* fix: hinted scalar mul

* feat: hinted g1p equal verify

* hinted_quad_miller_with_c_wi but test can not be run

* fix: memory issues

* fix: curves.rs memory issues

* fix: utils.rs memory issues

* change the hinted scripts for Fq12, Fq6, Fq2

* fix: quad miller memory issue

* fix: quad miller loop test

* G1Projective.hinted_into_affine

* feat: hinted msm

* hinted_groth16_verifier done

* uncomment lines that push hints

* add push_not_montgomery functions

* get rid of some warnings unused imports

* fix is_one tests and Fq12::hinted_mul

* test: hinted f1 equal verify

* fix double BigInt import

* Integrate Stack Analyzer (BitVM#94)

* Use lucid branch for script macro

* Add stack_hint

* More chunk script tests

* Add DEBUG to u8_extract_hbit

* Add Debug to the start of u32_rrot

* Add stack_hint to u32_rrot

* Add stack hints to u8_{xor, and, or}

* Add stack hint to bigint copy

* Add stack hints to blake3

* Add a stack hint to batched_scalar_mul op_picks

* Write analyzed chunk stats to file

* Fix the batched_scalar_mul stack hint

* Fix wrong stack hint for blake3

* Integrate chunker stack limit changes

* Fix stack hints; Change run to analyze stack

* Refactor execute_script to run()

---------

Co-authored-by: Lukas <[email protected]>

* Use run() instead of execute_script()

* [FIX] Fix running tests procedure (BitVM#97)

* Merge into_projective fix from BitVM#92

* TMUL Optimization (BitVM#99)

* perf: tmul addition's optimization

* perf: remove add with 0

* optimize limb_with_carry_prevent_overflow functions

* perf: get window optimization

* fix: tmul

* refactor: clean

---------

Co-authored-by: Hakan Karakuş <[email protected]>

* Fix inv stack hint

* Fix batched_scalar_mul stack hint

* Fix: Non constant program flow in scalar_mul (BitVM#101)

Co-authored-by: Lukas <[email protected]>

* Revert changes to add and double

* Optimize "limb_add_with_carry_prevent_overflow" and "limb_lshift_with_carry_prevent_overflow" (BitVM#102)

* Optimization of limb_add_with_carry_prevent_overflow

* optimize limb_lshift_with_carry_prevent_overflow overflow checks

---------

Co-authored-by: Hakan Karakuş <[email protected]>

* Tests: Refactor and print stack info

* Add `u32x8.rs`

* feat: On-demand serialization in blake3 (BitVM#105)

* chore: add blake3 u32

* feat: add u32_compress

* bugfix

* fmt

* chore: update data

---------

Co-authored-by: anothebody <[email protected]>

* optimize u32_add_carry from 145 to 90 bytes (BitVM#106)

* optimize u32_add_carry from 145 to 90 bytes

* optimize u32_add_nocarry from 95 to 80 bytes

* Add `u32_sub_noborrow`

* Affine versioned MSM  (BitVM#114)

* affine mode of scalar mul done

* test for groth16 verifier done

* fix G2 element subgroup membership check (BitVM#115)

* Optimize Fq2 mul (hinted) to use 2 lc2 instead of 3 lc1 tmuls & Fix Fq neg (BitVM#116)

* add BigInt option to hint and create Fq::hinted_mul_lc2

* Fq2::hinted_mul using 2 tmul_lc2 instead of 3 tmul, and fix Fq::neg now gives 0 for negative 0 instead of p

* Update `u32x8.rs`

* Hint msm affine (BitVM#117)

* G1Affine hinted_add example

* WIP: remain some problems

* fix compile error

* WIP: fix bug and add test

* WIP:fix hinted_check_add and hinted_scalar_mul_by_constant_g1

* pass test hinted_groth16_verifier

* Add `blake3_var_length_copy`

* Update `blake3_u32.rs`

* Create LICENSE

* Fix `u32_compress`/`u32_uncompress`

* feat: optimize winternitz (BitVM#121)

* feat: Add helper functions to use signatures as witness (BitVM#123)

* change algebra dependency to the version with new ATE_LOOP_COUNT (BitVM#124)

* feat:  implement the g2_subgroup check (BitVM#125)

* chore: add demo

* chore: add it to mod

---------

Co-authored-by: anothebody <[email protected]>

* helper to dry-run transaction scripts (BitVM#130)

* Remove obsolete methods

* Add missing dep

* Clean up Winternitz signing code and use `execute_script` to get passing tests

* Fix sftp threading issue (BitVM#85)

* Work on fixing sftp thread issue

* Fix disconnect timeouts with SFTP

* Work on handling file path

* Rework test order

* Fix data_store constructor

---------

Co-authored-by: ivebeenherebefore <[email protected]>

---------

Co-authored-by: robinlinus <[email protected]>
Co-authored-by: ivebeenherebefore <[email protected]>
Co-authored-by: PayneJoe <[email protected]>
Co-authored-by: Harry <[email protected]>
Co-authored-by: aristotleee <[email protected]>
Co-authored-by: StarDumpling <[email protected]>
Co-authored-by: timesaved12345 <[email protected]>
Co-authored-by: mac user <[email protected]>
Co-authored-by: franklynot <[email protected]>
Co-authored-by: stardustPandora <[email protected]>
Co-authored-by: Lukas <[email protected]>
Co-authored-by: bbist <[email protected]>
Co-authored-by: FatihSolak <[email protected]>
Co-authored-by: Hakan Karakuş <[email protected]>
Co-authored-by: fatih <[email protected]>
Co-authored-by: Hakan Karakuş <[email protected]>
Co-authored-by: stardustPandora <[email protected]>
Co-authored-by: fiamma-dev <[email protected]>
Co-authored-by: aiden-bitcoin <[email protected]>
Co-authored-by: Hakkush-07 <[email protected]>
Co-authored-by: Lukas George <[email protected]>
Co-authored-by: ostadgeorge <[email protected]>
Co-authored-by: chickenblock <[email protected]>
Co-authored-by: erray <[email protected]>
Co-authored-by: stillsaiko <[email protected]>
Co-authored-by: anothebody <[email protected]>
Co-authored-by: dylanCai9 <[email protected]>
Co-authored-by: sander2 <[email protected]>
Co-authored-by: archidoge0 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants