For montgomery squaring
const SAMPLES: usize = 10000;
for i in 1..(2 * N) {
r[2 * N - i] = (r[2 * N - i] << 1) | (r[2 * N - (i + 1)] >> 63);
}
function [ output_args ] = saveFigure( handle, fileName ) | |
% saveFigure | |
% Saves figure specified by `handle` as `fileName` in fullscreen | |
% as to get around the stupid behavior. | |
screen_size = get(0, 'ScreenSize'); | |
origSize = get(handle, 'Position'); % grab original on screen size | |
set(handle, 'Position', [0 0 screen_size(3) screen_size(4) ] ); %set to scren size | |
set(handle,'PaperPositionMode','auto') %set paper pos for printing | |
saveas(handle, fileName) % save figure |
from web3 import Web3, HTTPProvider, Account | |
from zksync_sdk import ZkSyncProviderV01, HttpJsonRPCTransport, network, ZkSync, EthereumProvider, Wallet, ZkSyncSigner, EthereumSignerWeb3, ZkSyncLibrary | |
import asyncio | |
from zksync_sdk.types import ChainId | |
from dataclasses import dataclass | |
@dataclass | |
class Network: | |
zksync_url: str |
# Finding the generators of G1 & G2 of a curve isogenous to BLS12-381, which has non-zero A, B coefficients in Short Weierstrass form. | |
# Script adapted from https://github.com/zkcrypto/bls12_381/blob/main/src/notes/design.rs | |
# Below are some links to the IETF draft where the isogeny is defined. | |
param = -0xd201000000010000 | |
def r(x): | |
return (x**4) - (x**2) + 1 | |
def q(x): | |
return (((x - 1) ** 2) * ((x**4) - (x**2) + 1) // 3) + x |
field_modulus = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 | |
desired_curve_order = 52435875175126190479447740508185965837690552500527637822603658699938581184513 | |
x = -0xd201000000010000 | |
Fp = GF(field_modulus) | |
Fr = GF(desired_curve_order) | |
X = Fp(x) | |
PARAM_A4 = 0 |
#!/bin/bash | |
diff=$(cargo fmt -- --check) | |
result=$? | |
if [[ ${result} -ne 0 ]] ; then | |
cat <<\EOF | |
There are some code style issues, run `cargo fmt` first. | |
EOF | |
exit 1 |