Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
947 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: WASM tests | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- develop | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
|
||
|
||
jobs: | ||
wasm_tests: | ||
name: run WASM tests | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: bindings/ergo-wallet-lib-wasm | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: install deps | ||
run: | | ||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f | ||
- name: run tests | ||
run: | | ||
wasm-pack build | ||
# wasm-pack test --firefox --headless | ||
# wasm-pack test --firefox --headless --release | ||
wasm-pack test --chrome --headless | ||
wasm-pack test --chrome --headless --release | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use k256::arithmetic::Scalar; | ||
use num_bigint::BigInt; | ||
// use std::convert::TryFrom; | ||
|
||
#[derive(Debug, PartialEq)] | ||
pub struct BigInteger(BigInt); | ||
|
||
impl From<BigInt> for BigInteger { | ||
fn from(b: BigInt) -> Self { | ||
BigInteger(b) | ||
} | ||
} | ||
|
||
impl From<Scalar> for BigInteger { | ||
fn from(s: Scalar) -> Self { | ||
let bytes = s.to_bytes(); | ||
BigInt::from_signed_bytes_be(&bytes[..]).into() | ||
} | ||
} | ||
|
||
// impl TryFrom<BigInteger> for Scalar { | ||
// type Error; | ||
// fn try_from(value: BigInteger) -> Result<Self, Self::Error> { | ||
// todo!() | ||
// } | ||
// } | ||
// | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::sigma_protocol::dlog_group; | ||
use std::convert::TryInto; | ||
|
||
#[test] | ||
fn scalar_conversion_roundtrip() { | ||
let s = dlog_group::random_scalar_in_group_range(); | ||
let b: BigInteger = s.into(); | ||
let bytes = b.0.to_signed_bytes_be(); | ||
let s2 = | ||
Scalar::from_bytes(bytes.as_slice().try_into().expect("expected 32 bytes")).unwrap(); | ||
let b2: BigInteger = s2.into(); | ||
assert_eq!(b, b2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.