rename sapvi namespace to drk

This commit is contained in:
narodnik
2021-05-22 15:45:02 +02:00
parent 153cae0234
commit 444770feda
21 changed files with 80 additions and 82 deletions

View File

@@ -1,13 +1,11 @@
[package]
name = "sapvi"
name = "darkfi"
version = "0.1.0"
authors = ["narodnik <x@x.org>"]
authors = ["darkfi <dev@dark.fi>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "sapvi"
name = "drk"
[dependencies]
ff = "0.8"

View File

@@ -1,8 +1,8 @@
## zklisp
This is a DSL for ZKVMCircuit from sapvi language.
This is a DSL for ZKVMCircuit from drk language.
It uses the mal (lisp) version of rust with some modifications to interact with bellman backend and also sapvi vm.
It uses the mal (lisp) version of rust with some modifications to interact with bellman backend and also drk vm.
## run

View File

@@ -17,7 +17,7 @@ use bls12_381;
use ff::{Field, PrimeField};
use rand::rngs::OsRng;
use sapvi::bls_extensions::BlsStringConversion;
use drk::bls_extensions::BlsStringConversion;
use std::ops::{AddAssign, MulAssign, SubAssign};

View File

@@ -2,7 +2,7 @@
use crate::types::LispCircuit;
use sapvi::BlsStringConversion;
use drk::BlsStringConversion;
use bellman::groth16;
use bls12_381::Bls12;

View File

@@ -1,5 +1,5 @@
use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError};
use sapvi::bls_extensions::BlsStringConversion;
use drk::bls_extensions::BlsStringConversion;
use std::rc::Rc;
use std::time::Instant;
use std::{cell::RefCell, collections::HashMap};

View File

@@ -1,5 +1,5 @@
# :set syntax=sapvi
# :source ../scripts/sapvi.vim
# :set syntax=drk
# :source ../scripts/drk.vim
const:
G_VCV: SubgroupPoint
G_VCR: SubgroupPoint

21
scripts/drk.vim Normal file
View File

@@ -0,0 +1,21 @@
if exists('b:current_syntax')
finish
endif
syn keyword drkKeyword assert enforce for in def return const as let emit contract private proof
syn keyword drkAttr mut
syn keyword drkType BinaryNumber Point Fr SubgroupPoint EdwardsPoint Scalar EncryptedNum list Bool U64 Num Binary
syn match drkFunction "\zs[a-zA-Z0-9_]*\ze("
syn match drkComment "#.*$"
syn match drkNumber '\d\+'
syn match drkConst '[A-Z_]\{2,}[A-Z0-9_]*'
hi def link drkKeyword Statement
hi def link drkAttr StorageClass
hi def link drkType Type
hi def link drkFunction Function
hi def link drkComment Comment
hi def link drkNumber Constant
hi def link drkConst Constant
let b:current_syntax = "drk"

View File

@@ -5,37 +5,37 @@
"autocmd BufRead *.pism call SetPismOptions()
"function SetPismOptions()
" set syntax=pism
" source /home/narodnik/src/sapvi/scripts/pism.vim
" source /home/narodnik/src/drk/scripts/pism.vim
"endfunction
if exists('b:current_syntax')
finish
endif
syn keyword sapviKeyword constant contract start end constraint
"syn keyword sapviAttr
syn keyword sapviType FixedGenerator BlakePersonalization PedersenPersonalization ByteSize U64 Fr Point Bool Scalar BinarySize
syn keyword sapviFunctionKeyword enforce lc0_add_one lc1_add_one lc2_add_one lc_coeff_reset lc_coeff_double lc0_sub_one lc1_sub_one lc2_sub_one dump_alloc dump_local
syn match sapviFunction "^[ ]*[a-z_0-9]* "
syn match sapviComment "#.*$"
syn match sapviNumber ' \zs\d\+\ze'
syn match sapviHexNumber ' \zs0x[a-z0-9]\+\ze'
syn match sapviConst '[A-Z_]\{2,}[A-Z0-9_]*'
syn keyword sapviBoolVal true false
syn match sapviPreproc "{%.*%}"
syn match sapviPreproc2 "{{.*}}"
syn keyword drkKeyword constant contract start end constraint
"syn keyword drkAttr
syn keyword drkType FixedGenerator BlakePersonalization PedersenPersonalization ByteSize U64 Fr Point Bool Scalar BinarySize
syn keyword drkFunctionKeyword enforce lc0_add_one lc1_add_one lc2_add_one lc_coeff_reset lc_coeff_double lc0_sub_one lc1_sub_one lc2_sub_one dump_alloc dump_local
syn match drkFunction "^[ ]*[a-z_0-9]* "
syn match drkComment "#.*$"
syn match drkNumber ' \zs\d\+\ze'
syn match drkHexNumber ' \zs0x[a-z0-9]\+\ze'
syn match drkConst '[A-Z_]\{2,}[A-Z0-9_]*'
syn keyword drkBoolVal true false
syn match drkPreproc "{%.*%}"
syn match drkPreproc2 "{{.*}}"
hi def link sapviKeyword Statement
"hi def link sapviAttr StorageClass
hi def link sapviPreproc PreProc
hi def link sapviPreproc2 PreProc
hi def link sapviType Type
hi def link sapviFunction Function
hi def link sapviFunctionKeyword Function
hi def link sapviComment Comment
hi def link sapviNumber Constant
hi def link sapviHexNumber Constant
hi def link sapviConst Constant
hi def link sapviBoolVal Constant
hi def link drkKeyword Statement
"hi def link drkAttr StorageClass
hi def link drkPreproc PreProc
hi def link drkPreproc2 PreProc
hi def link drkType Type
hi def link drkFunction Function
hi def link drkFunctionKeyword Function
hi def link drkComment Comment
hi def link drkNumber Constant
hi def link drkHexNumber Constant
hi def link drkConst Constant
hi def link drkBoolVal Constant
let b:current_syntax = "pism"

View File

@@ -1,21 +0,0 @@
if exists('b:current_syntax')
finish
endif
syn keyword sapviKeyword assert enforce for in def return const as let emit contract private proof
syn keyword sapviAttr mut
syn keyword sapviType BinaryNumber Point Fr SubgroupPoint EdwardsPoint Scalar EncryptedNum list Bool U64 Num Binary
syn match sapviFunction "\zs[a-zA-Z0-9_]*\ze("
syn match sapviComment "#.*$"
syn match sapviNumber '\d\+'
syn match sapviConst '[A-Z_]\{2,}[A-Z0-9_]*'
hi def link sapviKeyword Statement
hi def link sapviAttr StorageClass
hi def link sapviType Type
hi def link sapviFunction Function
hi def link sapviComment Comment
hi def link sapviNumber Constant
hi def link sapviConst Constant
let b:current_syntax = "sapvi"

View File

@@ -2,9 +2,9 @@ use async_executor::Executor;
use easy_parallel::Parallel;
use std::sync::Arc;
use sapvi::Result;
use drk::Result;
use sapvi::service::GatewayService;
use drk::service::GatewayService;
async fn start(executor: Arc<Executor<'_>>) -> Result<()> {
let gateway = GatewayService::new(
@@ -29,7 +29,7 @@ fn main() -> Result<()> {
smol::future::block_on(async move {
start(ex2).await?;
drop(signal);
Ok::<(), sapvi::Error>(())
Ok::<(), drk::Error>(())
})
});

View File

@@ -2,8 +2,8 @@ use async_executor::Executor;
use async_std::sync::{Arc, Mutex};
use easy_parallel::Parallel;
use sapvi::service::{fetch_slabs_loop, GatewayClient};
use sapvi::Result;
use drk::service::{fetch_slabs_loop, GatewayClient};
use drk::Result;
async fn start(executor: Arc<Executor<'_>>) -> Result<()> {
let mut client = GatewayClient::new(String::from("tcp://127.0.0.1:3333"));
@@ -43,7 +43,7 @@ fn main() -> Result<()> {
smol::future::block_on(async move {
start(ex2).await?;
drop(signal);
Ok::<(), sapvi::Error>(())
Ok::<(), drk::Error>(())
})
});

View File

@@ -9,7 +9,7 @@ use winit::{
window::Window,
};
use sapvi::gfx::{camera, model, texture};
use drk::gfx::{camera, model, texture};
use model::{DrawModel, Vertex};

View File

@@ -1,10 +1,10 @@
extern crate clap;
use async_executor::Executor;
use easy_parallel::Parallel;
use sapvi::rpc::adapter::RpcAdapter;
use sapvi::rpc::jsonserver;
use sapvi::rpc::options::ProgramOptions;
use sapvi::Result;
use drk::rpc::adapter::RpcAdapter;
use drk::rpc::jsonserver;
use drk::rpc::options::ProgramOptions;
use drk::Result;
use std::sync::Arc;
/*
@@ -23,7 +23,7 @@ async fn start2(executor: Arc<Executor<'_>>, options: ProgramOptions) -> Result<
let protocol = ServerProtocol::new(connections.clone(), accept_addr, stored_addrs2);
server_task = Some(executor.spawn(async move {
protocol.start(executor2).await?;
Ok::<(), sapvi::Error>(())
Ok::<(), drk::Error>(())
}));
}
@@ -205,7 +205,7 @@ fn main() -> Result<()> {
smol::future::block_on(async move {
jsonserver::start(ex2, options, adapter).await?;
drop(signal);
Ok::<(), sapvi::Error>(())
Ok::<(), drk::Error>(())
})
});

View File

@@ -1,5 +1,5 @@
use bls12_381::Scalar;
use sapvi::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
use drk::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
use std::fs::File;
use std::time::Instant;

View File

@@ -1,6 +1,6 @@
use bls12_381::Scalar;
use ff::Field;
use sapvi::{Decodable, ZKContract};
use drk::{Decodable, ZKContract};
use std::fs::File;
use std::ops::{Add, AddAssign, MulAssign, Neg, SubAssign};
use std::time::Instant;

View File

@@ -1,7 +1,7 @@
use ff::Field;
use group::Group;
use sapvi::crypto::{
use drk::crypto::{
create_mint_proof, load_params, save_params, setup_mint_prover, verify_mint_proof,
};

View File

@@ -1,4 +1,4 @@
use sapvi::{Decodable, ZKContract};
use drk::{Decodable, ZKContract};
use std::fs::File;
use std::time::Instant;

View File

@@ -4,7 +4,7 @@ use blake2s_simd::Params as Blake2sParams;
use ff::{Field, PrimeField};
use group::{Curve, GroupEncoding};
use sapvi::crypto::{
use drk::crypto::{
create_spend_proof, load_params, save_params, setup_spend_prover, verify_spend_proof,
};

View File

@@ -4,7 +4,7 @@ use ff::{Field, PrimeField};
use rand::rngs::OsRng;
use std::path::Path;
use sapvi::crypto::{
use drk::crypto::{
coin::Coin,
load_params,
merkle::{CommitmentTree, IncrementalWitness},
@@ -13,9 +13,9 @@ use sapvi::crypto::{
nullifier::Nullifier,
save_params, setup_mint_prover, setup_spend_prover,
};
use sapvi::serial::{Decodable, Encodable};
use sapvi::state::{state_transition, ProgramState, StateUpdate};
use sapvi::tx;
use drk::serial::{Decodable, Encodable};
use drk::state::{state_transition, ProgramState, StateUpdate};
use drk::tx;
struct MemoryState {
// The entire merkle tree state

View File

@@ -1,7 +1,7 @@
#[macro_use]
extern crate clap;
use bls12_381::Scalar;
use sapvi::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
use drk::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
use simplelog::*;
use std::fs;
use std::fs::File;

View File

@@ -5,7 +5,7 @@
use std::time::{Duration, Instant};
// from string scalar
use sapvi::bls_extensions::BlsStringConversion;
use drk::bls_extensions::BlsStringConversion;
// Bring in some tools for using finite fiels
use ff::PrimeField;