0

I'm trying to import and use a library to verify ring signatures. On doing so I'm getting an error while loading smart contract using w3.eth.contract(abi=abi, bytecode=bytecode). ValueError at /sc/deploy/1 Could not format invalid value '6080604052348...... as field 'bytecode' I'm getting this issue only when I make a call to AOSRing.Verify(pubkeys, tees, seed, message) function. There is no issue when this function is commented and rest of the codes including import of library is kept the same.

My smart contract election.sol is as follows:

pragma solidity >= 0.4.0 < 0.9.0;
import "D:/Msc/third_Sem/Project/BlockchainVoting/solcrypto/contracts/AOSRing.sol"; // as aring;   
contract ElectionContract {
...
function verifyRingSignature( uint256[] memory pubkeys, uint256[] memory tees, uint256 seed, uint256 message ) public view returns(bool) {
        return AOSRing.Verify(pubkeys, tees, seed, message);
}

The bytecode is:

60806040525050565b6000601f19601f83011690509190505600a265627a7a7230582057425571c394dc1300db6214812d96c02c5...D:/Msc/third_Sem/Project/Blockch...6612292576000848401525b50505050565b6000601f19601f83011690509190505600a265627a7a7230582057425571c394dc1300db6214812d96c02c53b0d6de81a9fe43a70a9bf6ddad906c6578706572696d656e74616cf50037

Note: I have truncated my byte code as it is almost 4-5 pages long. Three dots are used to represent the omitted numbers. The abi is:

        "abi": [
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "candidate_count",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "regions",
                "outputs": [
                    {
                        "name": "id",
                        "type": "uint256"
                    },
                    {
                        "name": "name",
                        "type": "string"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "end_time",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": false,
                "inputs": [
                    {
                        "name": "_vote",
                        "type": "string"
                    },
                    {
                        "name": "_signature",
                        "type": "string"
                    },
                    {
                        "name": "_keyImage",
                        "type": "string"
                    },
                    {
                        "name": "_rgn",
                        "type": "uint256"
                    }
                ],
                "name": "castVote",
                "outputs": [],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "pubkeys",
                        "type": "uint256[]"
                    },
                    {
                        "name": "tees",
                        "type": "uint256[]"
                    },
                    {
                        "name": "seed",
                        "type": "uint256"
                    },
                    {
                        "name": "message",
                        "type": "uint256"
                    }
                ],
                "name": "verifyRingSignature",
                "outputs": [
                    {
                        "name": "",
                        "type": "bool"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "_regionIndex",
                        "type": "uint256"
                    }
                ],
                "name": "getCandidates",
                "outputs": [
                    {
                        "name": "",
                        "type": "string[]"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "usedKeyImages",
                "outputs": [
                    {
                        "name": "",
                        "type": "string"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "no_of_shares",
                "outputs": [
                    {
                        "name": "",
                        "type": "int32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "public_verification_key",
                "outputs": [
                    {
                        "name": "",
                        "type": "int32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "region_count",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": false,
                "inputs": [
                    {
                        "name": "_id_db",
                        "type": "uint256"
                    },
                    {
                        "name": "election_region",
                        "type": "string"
                    }
                ],
                "name": "addRegion",
                "outputs": [],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "ring_size",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "parties",
                "outputs": [
                    {
                        "name": "",
                        "type": "string"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "public_shares",
                "outputs": [
                    {
                        "name": "",
                        "type": "int32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    },
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "candidates",
                "outputs": [
                    {
                        "name": "id_db",
                        "type": "uint256"
                    },
                    {
                        "name": "rgn",
                        "type": "uint256"
                    },
                    {
                        "name": "name",
                        "type": "string"
                    },
                    {
                        "name": "party",
                        "type": "string"
                    },
                    {
                        "name": "election_sign",
                        "type": "string"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "start_time",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    },
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "casted_votes",
                "outputs": [
                    {
                        "name": "vote",
                        "type": "string"
                    },
                    {
                        "name": "signature",
                        "type": "string"
                    },
                    {
                        "name": "keyImage",
                        "type": "string"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "owner",
                "outputs": [
                    {
                        "name": "",
                        "type": "address"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "voter_count",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "threshold_of_shares",
                "outputs": [
                    {
                        "name": "",
                        "type": "int32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": false,
                "inputs": [
                    {
                        "name": "_id_db",
                        "type": "uint256"
                    },
                    {
                        "name": "_rgn",
                        "type": "uint256"
                    },
                    {
                        "name": "_name",
                        "type": "string"
                    },
                    {
                        "name": "_party",
                        "type": "string"
                    },
                    {
                        "name": "_election_sign",
                        "type": "string"
                    }
                ],
                "name": "addCandidate",
                "outputs": [],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "casted_vote_count",
                "outputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": false,
                "inputs": [
                    {
                        "name": "_id_db",
                        "type": "uint256"
                    },
                    {
                        "name": "_otpk",
                        "type": "string"
                    },
                    {
                        "name": "_R",
                        "type": "string"
                    },
                    {
                        "name": "_rgn",
                        "type": "uint256"
                    }
                ],
                "name": "addVoter",
                "outputs": [],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [
                    {
                        "name": "",
                        "type": "uint256"
                    },
                    {
                        "name": "",
                        "type": "uint256"
                    }
                ],
                "name": "voters",
                "outputs": [
                    {
                        "name": "otpk",
                        "type": "string"
                    },
                    {
                        "name": "R",
                        "type": "string"
                    },
                    {
                        "name": "rgn",
                        "type": "uint256"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "constant": true,
                "inputs": [],
                "name": "modulus",
                "outputs": [
                    {
                        "name": "",
                        "type": "int32"
                    }
                ],
                "payable": false,
                "stateMutability": "view",
                "type": "function"
            },
            {
                "inputs": [],
                "payable": false,
                "stateMutability": "nonpayable",
                "type": "constructor"
            }
        ],

My library AOSRing.sol is:

pragma solidity >=0.4.0;
// pragma solidity >=0.4.14;

import "./Curve.sol";
import "./Schnorr.sol";

// https://www.iacr.org/cryptodb/archive/2002/ASIACRYPT/50/50.pdf
library AOSRing
{
    function Verify( uint256[] pubkeys, uint256[] tees, uint256 seed, uint256 message )
        public constant
        returns (bool)
    {
        return false;
        require( pubkeys.length % 2 == 0 );
        require( pubkeys.length > 0 );
        // TODO: verify seed
        // TODO: fit message to Curve.N()
        uint256 c = seed;
        uint256 nkeys = pubkeys.length / 2;
        for( uint256 i = 0; i < nkeys; i++ ) {
            uint256 j = i * 2;
            c = Schnorr.CalcProof([pubkeys[j], pubkeys[j+1]], message, tees[i], c);
        }
        return c == seed;
    }
    function test() public returns(bool){
        return false;
    }
}

After many hours with the help of this I could figure out that I have __D:/Msc/third_Sem/Project/Blockch__ embedded within my bytecode. I have no idea how to deal with this kind of situation. Any suggestion would be a great help! Thanks!

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.