This file contains hidden or 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
| import z3 | |
| s = z3.Solver() | |
| bvp = 256 | |
| bvs = 2**bvp | |
| balanceOf_signer = z3.BitVec('balanceOf_signer', bvp) | |
| wad = z3.BitVec('wad', bvp) | |
| reward = z3.BitVec('reward', bvp) | |
| contract_balance = z3.Int('contract_balance') # z3.IntVal((10**18) * 4.48) | |
| # Calculate balance of user after performing withdrawal |
This file contains hidden or 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
| pragma solidity ^0.8.9; | |
| contract E2Example | |
| { | |
| event EncryptedResponse(bytes32 nonce, bytes data); | |
| event DecryptedInput(uint256 a, uint256 b, uint256 c); | |
| event PublicKey(bytes32 x); |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| if [[ -z $1 ]]; then | |
| >&2 echo "Usage: `basename $0` [N.M|latest]" | |
| >&2 echo "" | |
| >&2 echo "Example to download v0.7.2:" | |
| >&2 echo "" | |
| >&2 echo ' $' "`basename $0` 7.2" | |
| >&2 echo "" | |
| >&2 echo "Example to download latest version:" |
This file contains hidden or 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
| #pragma once | |
| #include <functional> | |
| template<typename... ArgsT> | |
| struct EventHook; | |
| template<typename... ArgsT> |
This file contains hidden or 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
| /// Conditionally enable a function if they share the same CurveT type | |
| /// e.g. template<IsSameCurve<CurveT,OtherType> = 0> | |
| template<typename MyCurve, typename OtherType> | |
| using IsSameCurve = std::enable_if_t<std::is_same<MyCurve,typename OtherType::CurveT>::value,int>; | |
| /// Conditionally enable a function if the are of the same types and curves | |
| /// Uses CanonicalSelfT to determine if they're the same general type | |
| /// e.g. template<IsSameCurve<CurveT,OtherType> = 0> |
This file contains hidden or 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
| def text2sms(text): | |
| pairs = [' ', '!', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz'] | |
| mapping = {c:(str(i)*(j+1)) for i,p in enumerate(pairs) for j, c in enumerate(p)} | |
| return '-'.join(mapping[c] for c in text if c in mapping) |
This file contains hidden or 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
| import re | |
| from pypeg2 import word, attr, maybe_some, blank, endl, parse, optional | |
| from collections import defaultdict | |
| class ExprBase(str): | |
| pass | |
| class Expression(ExprBase): | |
| def __str__(self): | |
| return str(self.inside) + ''.join([str(_) for _ in self.rhs]) |
This file contains hidden or 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
| """ | |
| https://cryptosith.org/michael/data/talks/2013-08-01-SIAMAG13.pdf | |
| https://www.issac-conference.org/2015/Slides/Schost.pdf | |
| http://www.craigcostello.com.au/pairings/PairingsForBeginners.pdf | |
| """ | |
| fresh_compute = False # Perform expensive-(ish) computations for curve orders | |
| field_modulus = 22369874298875696930346742206501054934775599465297184582183496627646774052458024540232479018147881220178054575403841904557897715222633333372134756426301062487682326574958588001132586331462553235407484089304633076250782629492557320825577 | |
| desired_curve_order = 258664426012969094010652733694893533536393512754914660539884262666720468348340822774968888139573360124440321458177 |
This file contains hidden or 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
| # Let (L, R) = x, 0 | |
| # for i in range(128): (L, R) = (L, R) ** 3 + (k_i1, k_i2) (interpreting the two values as an element of some quadratic field over F_p, | |
| # so the # actual equations are newL = L**3 + 3*q*L*R**2 + k_i1, newR = 3*L**2*R + q*R**3 + k_i2, | |
| from random import randint | |
| q = 21888242871839275222246405745257275088696311157297823662689037894645226208583 | |
| q = 199 |
This file contains hidden or 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
| field_modulus = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787 | |
| desired_curve_order = 52435875175126190479447740508185965837690552500527637822603658699938581184513 | |
| Fp = GF(field_modulus) | |
| PARAM_A4 = 0 | |
| PARAM_A6 = 4 | |
| E = EllipticCurve(Fp, [PARAM_A4, PARAM_A6]) | |
| E_order = E.order() |