Skip to content

Instantly share code, notes, and snippets.

Zero Knowledge Proofs are super interesting. There is a large assortment of literature dedicated to studying commitment schemes, soundness, and completeness.

Thankfully, we can just ignore all that literature and come up with a random number.

In this challenge, we are assuming that the prover (the server that we connect to and query), will commit all of its values before we check a given clause. Since this is a standard 3-SAT problem, the clauses are recorded in conjunctive normal form (a fancy way to say that they are all OR'd together), and each clause must evaluate to True. So, a perfect prover will never have a clause that consists of all Falses. This allows us to write a simple check for a bad prover:

if True not in arr:
  r.sendline('false')
  break
mod codec;
use crate::codec::MQTTCodec;
use std::error::Error;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use tokio::net::{TcpListener, TcpStream};
use tokio_util::codec::{Framed};
use std::collections::HashMap;
use std::sync::Arc;
use std::ops::DerefMut;
use tokio::net::{TcpListener, TcpStream};
use tokio_util::codec::Framed;
use tokio::sync::Mutex;
use tokio::time;
use tokio::time::{Duration};
impl Broker {
pub fn new() -> Broker {
Broker {
state: Arc::new(Mutex::new(BrokerState::new()))
}
}
pub async fn start_server(self, addr: IpAddr, port: u16) -> Result<(), Box<dyn Error>> {
let address = SocketAddr::new(addr, port);
let mut listener = TcpListener::bind(address).await?;
@Heasummn
Heasummn / vexTurningPoint.c
Created October 10, 2018 21:57
vexTurningPoint.c
#pragma config(Sensor, in1, gyro, sensorGyro)
#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl6, puncherLimit, sensorTouch)
#pragma config(Sensor, dgtl11, leftEncoder, sensorQuadEncoder)
#pragma config(Motor, port1, launcher1, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, left1, tmotorVex393HighSpeed_MC29, openLoop, driveLeft, encoderPort, dgtl11)
#pragma config(Motor, port3, left2, tmotorVex393HighSpeed_MC29, openLoop, driveLeft)
#pragma config(Motor, port4, intake, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, lift, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, capIntake, tmotorVex393_MC29, openLoop)
static const float kp = 10;
void move(int leftPower, int rightPower) {
motor[left1] = leftPower;
motor[left2] = leftPower;
motor[right1] = rightPower;
motor[right2] = rightPower;
}
float driveForward(int power, float distance) {
@Heasummn
Heasummn / vexCode.c
Created January 10, 2018 23:52
Vex Code for our robot completely OP
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, in1, armPent, sensorPotentiometer)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, backRight, tmotorVex393_HBridge, openLoop, reversed)
#pragma config(Motor, port2, frontLeft, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, leftIntake, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, rightLift, tmotorVex393_MC29, openLoop, encoderPort, I2C_2)
#pragma config(Motor, port5, claw, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, leftLift, tmotorVex393_MC29, openLoop, reversed, encoderPort, I2C_1)
#include <stdio.h>
struct node
{
int data;
struct node * next;
};
int main()
{
public int factorial(int n)
{
int total = 1;
for(int i = 1; i < n; n++)
{
total *= i;
}
return total;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#define LESSON_NAME_MAX 12
#define SCHOOL_DAYS_IN_WEEK 5
#define TEACHER_NAME_MAX 5
#define LESSONS_PER_DAY_MAX 8