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
    
  
  
    
  | const webcrypto = require('crypto').webcrypto.subtle; | |
| const enc = new TextEncoder(); | |
| function bytesToBase64url(bytes) { | |
| return Buffer.from(bytes).toString('base64url'); | |
| } | |
| function jsonToBase64url(obj) { | |
| const bytes = enc.encode(JSON.stringify(obj)); | 
  
    
      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
    
  
  
    
  | // SPDX-License-Identifier: GPL-3.0 | |
| pragma solidity >=0.7.0 <0.9.0; | |
| library ECDSA { | |
| /** | |
| * @notice Recovers the address for an ECDSA signature and message hash, | |
| * note that the hash must be prefixed with "\x19Ethereum Signed Message:\n{msg.length}" | |
| * @return address The address that was used to sign the message | |
| */ | 
  
    
      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
    
  
  
    
  | // SPDX-License-Identifier: GPL-3.0 | |
| pragma solidity >=0.7.0 <0.9.0; | |
| contract Lottery { | |
| // PRICE PER TICKET | |
| uint256 constant TICKET_PRICE = (10 ** 18) / 100; // 0.01eth | |
| uint256 constant TICKET_OPTIONS = 30; | |
| uint256 constant OPTIONS_PER_TICKET = 3; | 
  
    
      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
    
  
  
    
  | // SPDX-License-Identifier: GPL-3.0 | |
| pragma solidity >=0.7.0 <0.9.0; | |
| library Vote { | |
| uint256 constant BITS_PER_CANDIDATE = 5; | |
| uint256 constant BITMASK = (2**BITS_PER_CANDIDATE) - 1; | |
| // Storage Layout: | |
| // Voter (160bit) | size (5bit) | votes (5~90bit) | 
NewerOlder