Skip to content

Instantly share code, notes, and snippets.

@skaunov
skaunov / my_first_package_tests.move
Created April 7, 2024 16:50
first-app/build-test #Dacade #Sui
#[test_only]
module my_first_package::my_first_package_tests {
// uncomment this line to import the module
use my_first_package::my_module;
const ENotImplemented: u64 = 0;
#[test]
public fun test_sword_create() {
let ctx = tx_context::dummy();
@skaunov
skaunov / wsadd.circom
Last active November 27, 2023 17:24
exercise 113 for ZKhack MMM
pragma circom 2.1.6;
include "circomlib/circuits/comparators.circom";
/* the exercise says "of a given field F", but I feel like it's really bigger task, which is quite narrow in it's learning
potential so the `template` is parameterized only with the curve coefficients */
// WARNING: it's for user discretion to ensure that both points are on the curve
template WsAdd (a) { // **parameter is $A$ coefficient of the curve**
signal input p_1[3];
signal input p_2[3];
use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{
parse_macro_input, spanned::Spanned, AngleBracketedGenericArguments, Data::Struct, DeriveInput,
Error, Fields::Named, GenericArgument, Ident, Meta, Path, PathArguments, Type, TypePath,
};
#[proc_macro_derive(Builder, attributes(builder))]
pub fn derive(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
/* It was few month ago I was busy with this solution, and I didn't left the note on the amendment to the exercise I wanted
to propose (since I wasn't sure it would be reasonable). Though I left the tag #result to indicate the problem that I saw.
IIRC I wanted to propose switching `Option` result from `new` method to `match_sting`. */
#![feature(iter_intersperse)]
use require_lifetimes::require_lifetimes;
#[derive(Debug, PartialEq, Eq, Clone)]
enum MatcherToken<'t> {
/// This is just text without anything special.
RawText(&'t str),
@skaunov
skaunov / Cargo.toml
Last active January 22, 2023 18:26
A concise write-up on Cryptopals challenge #48. See <https://dev.to/skaunov/cryptopals-challenge-48-solution-5dam> for context.
[package]
name = "challenges-47"
version = "0.1.0"
edition = "2021"
[dependencies]
rsa = "*"
rand = "*"
num-traits = "*"
num-bigint-dig = "*"
@skaunov
skaunov / cargo.toml
Last active January 20, 2023 21:40
Uncloak CryptoEng exercise 5.3 uncleaned solution
[package]
name = "trimmedSHA512"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4.0.29", features = ["derive"] }
sha2 = "*"