Skip to content

Instantly share code, notes, and snippets.

View gpestana's full-sized avatar
🧑‍🚀
the future is now

Gonçalo Pestana gpestana

🧑‍🚀
the future is now
View GitHub Profile
@gpestana
gpestana / paged_payout_worst_case_weight.rs
Created February 13, 2024 21:23
paged payout worst case weight
use frame_support::weights::{constants, Weight};
// from https://github.com/polkadot-fellows/runtimes/blob/main/relay/polkadot/constants/src/weights/rocksdb_weights.rs#L42
fn rocks_db_weight_reads(reads: u64) -> Weight {
(reads * 20_499 * constants::WEIGHT_REF_TIME_PER_NANOS).into()
}
fn rocks_db_weight_writes(writes: u64) -> Weight {
(writes * 83_471 * constants::WEIGHT_REF_TIME_PER_NANOS).into()
}
#[test]
fn no_untracked_moot_nominations() {
ExtBuilder::default().build_and_execute(|| {
// 101 nominates 11 and 21.
assert_eq!(Staking::status(&101), Ok(StakerStatus::Nominator(vec![11, 21])));
// validator 61 does not exist.
assert!(!(Nominators::<Test>::contains_key(61) && Validators::<Test>::contains_key(10)));
assert!(Staking::status(&61).is_err());
github.com/Yawning/cryptopan v0.0.0-20170504040949-65bca51288fe h1:SKdmPMOww/faIbffys2UgnZHlQJETCw7N18AaYUYf2M=
github.com/Yawning/cryptopan v0.0.0-20170504040949-65bca51288fe/go.mod h1:tGK+sH41V0mnyFBVWQoRyj7neHPwQwPM1KJ3PfS6dTI=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/libcontainer v2.2.1+incompatible h1:++SbbkCw+X8vAd4j2gOCzZ2Nn7s2xFALTf7LZKmM1/0=
github.com/docker/libcontainer v2.2.1+incompatible/go.mod h1:osvj61pYsqhNCMLGX31xr7klUBhHb/ZBuXS0o1Fvwbw=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8/yCZMuEPMUDHG0CW/brkkEp8mzqk2+ODEitlw=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
github.com/frankban/quicktest v1.11.3 h1:8sXhOn0uLys67V8EsXLc6eszDs8VXWxL3iRvebPhedY=
github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntU
{
"builtins": [
"output"
],
"data": [
290341444919459839,
1,
2345108766317314046,
4612671182993129469,
5198983563776393216,
@gpestana
gpestana / cairo-example.md
Last active October 20, 2021 13:26
program cairo
  1. Program:
func main(): 
  alloc_locals
  
  local input_ptr : felt*
  
  # populate input_ptr with inputs; verifier should not learn the value of the inputs
@gpestana
gpestana / pcommitment-curve25519.rs
Last active January 11, 2021 15:34
Pedersen commitment with curve25519_dalek
use curve25519_dalek::constants;
use curve25519_dalek::ristretto::RistrettoPoint;
use curve25519_dalek::scalar::Scalar;
use sha2::Sha512;
fn main() {
println!(">> Pederson Commitment with curve25519");
}
#[derive(Clone)]
@gpestana
gpestana / req_data.json
Last active March 12, 2020 17:25
data assign
{
"test_1": {
"non_reputable_wallets": ["4e844548-a23c-4a9d-8d4f-f137cd93c88c", "79ce17c9-97bf-417d-a181-54b9646bb79a", "861886ef-2d04-4145-a503-277c1ecd0773"],
"data": [
{
"ip_src": "95.40.123.251",
"wallet_id": "4e844548-a23c-4a9d-8d4f-f137cd93c88c",
"payload": [],
},
{
pragma solidity >=0.4.22 <0.6.0;
contract ElGamal {
function inner_product(uint256[2][1] memory ciphertext_vector, uint256[1] memory scalar_vector) public returns (uint256[2] memory)
{
uint256[2] memory aggregate = [uint256(0), uint256(0)];
uint256[2] memory mult = bn128_multiply([
ciphertext_vector[0][0],
## ~/.vimrc
" basic
syntax on
set tabstop=2
set number
set autoread
highlight LineNr ctermfg=blue
" 80 lines separation
zsc.methods.simulateAccounts(y, this._getEpoch()).call()
.then((result) => {
var r = bn128.randomScalar();
var L = y.map((party, i) => bn128.curve.g.mul(i == index[0] ? new BN(-value) : i == index[1] ? new BN(value) : new BN(0)).add(bn128.unserialize(party).mul(r)));
var R = bn128.curve.g.mul(r);
var CLn = result.map((simulated, i) => bn128.serialize(bn128.unserialize(simulated[0]).add(L[i])));
var CRn = result.map((simulated) => bn128.serialize(bn128.unserialize(simulated[1]).add(R)));
L = L.map(bn128.serialize);
R = bn128.serialize(R);
var proof = service.proveTransfer(CLn, CRn, L, R, y, state.lastRollOver, account.keypair['x'], r, value, state.available - value, index);