Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "cryptographic_sync-common"
version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0", default-features = false, features = ["derive", "std"] }
tendermint-light-client-verifier = { version = "0.35.0", default-features = false, features = [
"rust-crypto",
] }
p3-baby-bear = "0.1.3-succinct"
35 changes: 35 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use tendermint_light_client_verifier::types::LightBlock;
use serde::{Serialize, Deserialize};
use p3_baby_bear::BabyBear;

#[derive(Serialize, Deserialize)]
pub enum ProgramInput {
Recursive(RecursiveProgramInput),
Genesis {
hash: Vec<u8>,
header: LightBlock,
vkey: [u8; 32],
}
}

#[derive(Serialize, Deserialize)]
pub struct RecursiveProgramInput {
pub public_values: Vec<u8>,
pub genesis_hash: Vec<u8>,
pub recursive_proof_input: RecursiveProofInput,

pub previous_header: LightBlock,
pub current_header: LightBlock,

pub current_vkey: [BabyBear; 8],
pub previous_vkey: [BabyBear; 8],
}

#[derive(Serialize, Deserialize)]
pub enum RecursiveProofInput {
Sp1, // proof itself is passed via write_proof
Groth16 {
proof: Vec<u8>,
sp1_key: Vec<u8>,
}
}
Binary file added elf/riscv32im-succinct-zkvm-elf
Binary file not shown.
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
description = "Rust development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# Read the file relative to the flake's root
overrides = (builtins.fromTOML (builtins.readFile (self + "/rust-toolchain.toml")));
libPath = with pkgs; lib.makeLibraryPath [
# load external libraries that you need in your rust project here
pkgs.openssl
pkgs.stdenv.cc.cc.lib
];
in
{
devShells.default = pkgs.mkShell rec {
nativeBuildInputs = [ pkgs.pkg-config ];
buildInputs = with pkgs; [
clang
llvmPackages.bintools
rustup
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should just use Fenix instead, it has fromRustToolchainFile or similar

openssl
stdenv.cc.cc.lib
];

RUSTC_VERSION = overrides.toolchain.channel;

# https://github.com/rust-lang/rust-bindgen#environment-variables
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and further magic you do to make bindgen work nice can be achieved by just adding pkgs.rustPlatform.bindgenHook to build inputs

LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ];

shellHook = ''
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/
'';

# Add precompiled library to rustc search path
RUSTFLAGS = (builtins.map (a: ''-L ${a}/lib'') [
# add libraries here (e.g. pkgs.libvmi)
pkgs.openssl
pkgs.stdenv.cc.cc.lib

]);

LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (buildInputs ++ nativeBuildInputs);


# Add glibc, clang, glib, and other headers to bindgen search path
BINDGEN_EXTRA_CLANG_ARGS =
# Includes normal include path
(builtins.map (a: ''-I"${a}/include"'') [
# add dev libraries here (e.g. pkgs.libvmi.dev)
pkgs.glibc.dev
pkgs.openssl
pkgs.stdenv.cc.cc.lib
])
# Includes with special directory paths
++ [
''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"''
''-I"${pkgs.glib.dev}/include/glib-2.0"''
''-I${pkgs.glib.out}/lib/glib-2.0/include/''
];
};
}
);
}
Loading