Skip to content

Instantly share code, notes, and snippets.

Guide for building a ppzkpcd constraint system

Before reading this guide, you should get familar with definition of proof of carrying data. Section 5 of [BCCT13] gives a formal definition.

This guide is mainly based on the source file in zk_proof_systems/pcd/r1cs_pcd/compliance_predicate/. You can use the source files example/tally.hpp and example/tally.tcc as sample.

You need do define 5 classes in total. Each of them inherits from a base class. For each part, I will introduce all the variables and functions needed to be cared about.

  • Compliance Predicate Handler (Where to define your gadget)
  • Message (Edge label)
@learncfinaweek
learncfinaweek / gist:4121080
Created November 20, 2012 21:00
Decision Making and Scopes - Scopes

ColdFusion groups variables together in scopes, or a range in which a variable can be accessed. Think of a scope as a bucket of memory that can store variables. Each scope has its own purpose, and each scope has its own lifecycle.

The following table shows major scopes available in a running ColdFusion application:

  • Variables: Default scope available in ColdFusion templates. Variables are available only during the execution of the template.
diff -Naur sammy.orig/lib/plugins/sammy.template.js sammy/lib/plugins/sammy.template.js
--- sammy.orig/lib/plugins/sammy.template.js 2010-11-16 19:23:30.508730579 +0300
+++ sammy/lib/plugins/sammy.template.js 2010-11-16 19:23:51.988731323 +0300
@@ -19,22 +19,23 @@
// Generate a reusable function that will serve as a template
// generator (and which will be cached).
fn = srender_cache[name] = new Function("obj",
- "var p=[],print=function(){p.push.apply(p,arguments);};" +
+ "var ___$$$___=[],print=function(){___$$$___.push.apply(___$$$___,arguments);};" +
@zodoz
zodoz / gist:5152201
Created March 13, 2013 13:46
Useful PEGjs piece that can allow optional parts of a grammer to occur without a required order and be arrayed. Thus you can have only one block of "a"s, "b"s, and "c"s in any order, but as many blocks of "x"s, "y"s, and "z"s again in any order.
{var aDone = bDone = cDone = false;}
start = part part?
part = sets:set*
{
var ret = {};
for(var i=0;i<sets.length;i++) {
// add to set if it already exists
if(ret[sets[i].type] !== undefined) {
{
function styleProps() {
// size : style / config
return ['className', 'size', 'width', 'disabledLabel', 'textAlign', 'marginRight', 'marginLeft', 'marginTop', 'marginBottom', 'contentSpan'];
}
function configProps() {
return ['htmlType', 'dataSource', 'button', 'value', 'defaultValue', 'placeholder', 'type', 'html', 'autoWidth', 'max', 'min', 'addButtonLabel', 'indexFormat', 'mode', 'data-repeater', 'shape', 'previewHidden'];
}
function ruleProps() {
return ['rule', 'showPath'];
function factorialIterative(num) {
var result = 1;
for (var i=num; i>0; i--)
result *= i;
return result;
}
function factorial(num) {
if (num == 0)
return 1;
//option 1: define as a object
var myFn = {
duplicate: function(str, num) {
num = num || 2;
return (new Array(num + 1)).join(str);
},
reverse: function(str) {
return str.split("").reverse().join("");
},
chop: function(str, index, len) {
@Siilwyn
Siilwyn / if.js
Last active April 26, 2024 08:05
Multiple ways to handle the platform: switch vs. if...else vs. object
var getConfigDirectory = function () {
var platform = process.platform;
if (platform === 'linux') {
return process.env.XDG_CONFIG_HOME || path.join(home(), '.config')
}
else if (platform === 'darwin') {
return path.join(home(), 'Library', 'Preferences');
}
else if (platform === 'win32') {
//https://pegjs.org/online
start = table / trx
table = "table" space s:schema "." t:tablename ":" space a:action ":" d:data {return {schema:s, table:t, action:a, data:d};}
trx = trx_begin / trx_commit
trx_begin = "BEGIN" id:trx_id? {return {trx:"BEGIN", xid:id};}
trx_commit = "COMMIT" id:trx_id? tm:trx_tm {return {trx:"COMMIT", xid:id, time:tm};}