Last active
August 7, 2019 11:21
-
-
Save 0xbunyip/fcc1b8961e46fc09dbf71eabcf9a25e1 to your computer and use it in GitHub Desktop.
This file contains 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
@constant | |
@public | |
def instructionApproved( | |
isBeacon: bool, | |
instHash: bytes32, | |
height: uint256, | |
instPath: bytes32[INST_MAX_PATH], | |
instPathIsLeft: bool[INST_MAX_PATH], | |
instPathLen: int128, | |
instRoot: bytes32, | |
blkData: bytes32, | |
blkHash: bytes32, | |
signerSig: uint256, | |
numR: int128, | |
xs: uint256[COMM_SIZE], | |
ys: uint256[COMM_SIZE], | |
rIdxs: int128[COMM_SIZE], | |
numSig: int128, | |
sigIdxs: uint256[COMM_SIZE], | |
rp: bytes[PUBKEY_SIZE], | |
rpx: uint256, | |
rpy: uint256, | |
r: bytes[PUBKEY_SIZE], | |
) -> bool: | |
# Find committees signed this block | |
comm: bytes[PUBKEY_LENGTH] | |
numVals: uint256 | |
comm, numVals = self.findComm(height, isBeacon) | |
# Check if instRoot is in block with hash blkHash | |
blk: bytes32 = keccak256(concat(blkData, instRoot)) | |
if not blk == blkHash: | |
return False | |
# Check if enough validators signed this block | |
if convert(numSig, uint256) < 1 + numVals * 2 / 3: | |
return False | |
# Check that beacon signature is correct | |
if not self.verifySig( | |
comm, | |
signerSig, | |
numR, | |
xs, | |
ys, | |
rIdxs, | |
numSig, | |
sigIdxs, | |
rp, | |
rpx, | |
rpy, | |
r, | |
blk, | |
): | |
return False | |
# Check that inst is in beacon block | |
if not self.instructionInMerkleTree( | |
instHash, | |
instRoot, | |
instPath, | |
instPathIsLeft, | |
instPathLen, | |
): | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment