Last active
March 11, 2020 21:52
-
-
Save ralexstokes/5b97f96c128a98d9c066ac7db712445f to your computer and use it in GitHub Desktop.
Sketch of Clojure-like smart contract language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require | |
[types] | |
[precompiles] | |
[registry] | |
[tools]) | |
(defcontract BLSSignatureVerifier | |
(defn ^:public verify [message public-key signature) | |
(let [message-on-curve (precompiles/hash-to-curve message)] | |
(= | |
(precompiles/bls12-381-pairing {:args [...]}) | |
(precompiles/bls12-381-pairing {:args [...))) | |
(defcontract DepositVerifier | |
(defvar deposit-contract-address types/address) | |
(defvar bls-signature-verifier types/address) | |
(defn deposit->public-key [deposit] ...) | |
(defn deposit-hash-tree-root [deposit] ...) | |
(defn valid? [deposit signature] | |
(call bls-signature-verifier BLSSignatureVerifier/verify | |
{:args [(deposit-hash-tree-root deposit) (deposit->public-key deposit) signature]}) | |
(defn ^:public deposit-if-valid [deposit signature] | |
(if (valid? deposit signature) | |
(call deposit-contract-address (registry/deposit-contract :deposit) {:args [deposit signature] :gas 50000}) | |
(throw-with-reason "invalid deposit")))) | |
;; get the deployment bytecode for each contract | |
(map tools/compile-contract [BLSSignatureVerifier BLSSignatureVerifier]) | |
;; => (0x... 0x...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment