diff --git a/chains/arbitrum/contractsgen/contractsgen.go b/chains/arbitrum/contractsgen/contractsgen.go index 10c8fec..4c4f57c 100644 --- a/chains/arbitrum/contractsgen/contractsgen.go +++ b/chains/arbitrum/contractsgen/contractsgen.go @@ -32,7 +32,7 @@ var ( // FheOpsMetaData contains all meta data concerning the FheOps contract. var FheOpsMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"add\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"and\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"toType\",\"type\":\"uint8\"}],\"name\":\"cast\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"defaultValue\",\"type\":\"uint256\"}],\"name\":\"decrypt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"div\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"eq\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"getNetworkPublicKey\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"gt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"gte\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"s\",\"type\":\"string\"}],\"name\":\"log\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"lt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"lte\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"max\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"min\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"mul\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"ne\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"value\",\"type\":\"bytes\"}],\"name\":\"not\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"or\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"seed\",\"type\":\"uint64\"},{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"random\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"rem\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"req\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"rol\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"ror\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"ctHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"pk\",\"type\":\"bytes\"}],\"name\":\"sealOutput\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"controlHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"ifTrueHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"ifFalseHash\",\"type\":\"bytes\"}],\"name\":\"select\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"shl\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"shr\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"sub\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"toType\",\"type\":\"uint8\"},{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"trivialEncrypt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"verify\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"xor\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"add\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"and\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"toType\",\"type\":\"uint8\"}],\"name\":\"cast\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"defaultValue\",\"type\":\"uint256\"}],\"name\":\"decrypt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"div\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"eq\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"getNetworkPublicKey\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"gt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"gte\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"string\",\"name\":\"s\",\"type\":\"string\"}],\"name\":\"log\",\"outputs\":[],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"lt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"lte\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"max\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"min\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"mul\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"ne\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"value\",\"type\":\"bytes\"}],\"name\":\"not\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"or\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"uint64\",\"name\":\"seed\",\"type\":\"uint64\"},{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"random\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"rem\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"}],\"name\":\"req\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"rol\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"ror\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"ctHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"pk\",\"type\":\"bytes\"}],\"name\":\"sealOutput\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"controlHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"ifTrueHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"ifFalseHash\",\"type\":\"bytes\"}],\"name\":\"select\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"shl\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"shr\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"value\",\"type\":\"bytes\"}],\"name\":\"square\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"sub\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"uint8\",\"name\":\"toType\",\"type\":\"uint8\"},{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"trivialEncrypt\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"input\",\"type\":\"bytes\"},{\"internalType\":\"int32\",\"name\":\"securityZone\",\"type\":\"int32\"}],\"name\":\"verify\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"utype\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"lhsHash\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"rhsHash\",\"type\":\"bytes\"}],\"name\":\"xor\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"}]", } // FheOpsABI is the input ABI used to generate the binding from. @@ -1016,6 +1016,37 @@ func (_FheOps *FheOpsCallerSession) Shr(utype uint8, lhsHash []byte, rhsHash []b return _FheOps.Contract.Shr(&_FheOps.CallOpts, utype, lhsHash, rhsHash) } +// Square is a free data retrieval call binding the contract method 0xef432a33. +// +// Solidity: function square(uint8 utype, bytes value) pure returns(bytes) +func (_FheOps *FheOpsCaller) Square(opts *bind.CallOpts, utype uint8, value []byte) ([]byte, error) { + var out []interface{} + err := _FheOps.contract.Call(opts, &out, "square", utype, value) + + if err != nil { + return *new([]byte), err + } + + out0 := *abi.ConvertType(out[0], new([]byte)).(*[]byte) + + return out0, err + +} + +// Square is a free data retrieval call binding the contract method 0xef432a33. +// +// Solidity: function square(uint8 utype, bytes value) pure returns(bytes) +func (_FheOps *FheOpsSession) Square(utype uint8, value []byte) ([]byte, error) { + return _FheOps.Contract.Square(&_FheOps.CallOpts, utype, value) +} + +// Square is a free data retrieval call binding the contract method 0xef432a33. +// +// Solidity: function square(uint8 utype, bytes value) pure returns(bytes) +func (_FheOps *FheOpsCallerSession) Square(utype uint8, value []byte) ([]byte, error) { + return _FheOps.Contract.Square(&_FheOps.CallOpts, utype, value) +} + // Sub is a free data retrieval call binding the contract method 0xcc2cbeff. // // Solidity: function sub(uint8 utype, bytes lhsHash, bytes rhsHash) pure returns(bytes) @@ -1143,7 +1174,7 @@ func (_FheOps *FheOpsCallerSession) Xor(utype uint8, lhsHash []byte, rhsHash []b // PrecompilesMetaData contains all meta data concerning the Precompiles contract. var PrecompilesMetaData = &bind.MetaData{ ABI: "[{\"inputs\":[],\"name\":\"Fheos\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", - Bin: "0x60e3610052600b82828239805160001a607314610045577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806313d8d464146038575b600080fd5b603e6052565b604051604991906094565b60405180910390f35b608081565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006080826057565b9050919050565b608e816077565b82525050565b600060208201905060a760008301846087565b9291505056fea2646970667358221220f43d4e52abfbf8c9c208f884b148002b64d0676ad7790477868d71dbdec20ac664736f6c63430008130033", + Bin: "0x60e3610052600b82828239805160001a607314610045577f4e487b7100000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b30600052607381538281f3fe730000000000000000000000000000000000000000301460806040526004361060335760003560e01c806313d8d464146038575b600080fd5b603e6052565b604051604991906094565b60405180910390f35b608081565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006080826057565b9050919050565b608e816077565b82525050565b600060208201905060a760008301846087565b9291505056fea26469706673582212207ee41fa435c050c6db84eaa737c878ae138a25ddabc75d90fcb9d354fb3fbea264736f6c63430008130033", } // PrecompilesABI is the input ABI used to generate the binding from. diff --git a/nitro-overrides/precompiles/FheOps.go b/nitro-overrides/precompiles/FheOps.go index 03435e0..7768026 100644 --- a/nitro-overrides/precompiles/FheOps.go +++ b/nitro-overrides/precompiles/FheOps.go @@ -931,6 +931,42 @@ func (con FheOps) Shr(c ctx, evm mech, utype byte, lhsHash []byte, rhsHash []byt return ret, err } +func (con FheOps) Square(c ctx, evm mech, utype byte, value []byte) ([]byte, error) { + tp := fheos.TxParamsFromEVM(evm, c.caller) + if metrics.Enabled { + h := fmt.Sprintf("%s/%s/%s", "fheos", "Square", fheos.UtypeToString(utype)) + defer func(start time.Time) { + sampler := func() metrics.Sample { + return metrics.NewBoundedHistogramSample() + } + metrics.GetOrRegisterHistogramLazy(h, nil, sampler).Update(time.Since(start).Microseconds()) + }(time.Now()) + } + + ret, gas, err := fheos.Square(utype, value, &tp) + + if err != nil { + if metrics.Enabled { + c := fmt.Sprintf("%s/%s/%s/%s", "fheos", "Square", fheos.UtypeToString(utype), "error/fhe_failure") + metrics.GetOrRegisterCounter(c, nil).Inc(1) + } + return ret, err + } + + err = c.Burn(gas) + + if metrics.Enabled { + metricPath := fmt.Sprintf("%s/%s/%s/%s", "fheos", "Square", fheos.UtypeToString(utype), "success/total") + if err != nil { + metricPath = fmt.Sprintf("%s/%s/%s/%s", "fheos", "Square", fheos.UtypeToString(utype), "error/fhe_gas_failure") + } + + metrics.GetOrRegisterCounter(metricPath, nil).Inc(1) + } + + return ret, err +} + func (con FheOps) Sub(c ctx, evm mech, utype byte, lhsHash []byte, rhsHash []byte) ([]byte, error) { tp := fheos.TxParamsFromEVM(evm, c.caller) if metrics.Enabled { diff --git a/precompiles/contracts.go b/precompiles/contracts.go index 65350da..37a65d4 100644 --- a/precompiles/contracts.go +++ b/precompiles/contracts.go @@ -1583,3 +1583,9 @@ func GetNetworkPublicKey(securityZone int32, tp *TxParams) ([]byte, error) { return pk, nil } + +func Square(utype byte, value []byte, tp *TxParams) ([]byte, uint64, error) { + return Mul(utype, value, value, tp) + // Please don't delete the below comment, this is intentionally left here for code generation. + //ct := getCiphertext(storage, fhe.BytesToHash(value), tp.ContractAddress) +} diff --git a/precompiles/gas.go b/precompiles/gas.go index 22e5437..f789d45 100644 --- a/precompiles/gas.go +++ b/precompiles/gas.go @@ -57,7 +57,7 @@ func getRawPrecompileGas(precompileName types.PrecompileName, uintType fhe.Encry case fhe.Uint128: return 290000 } - case types.Mul: + case types.Mul, types.Square: switch uintType { case fhe.Uint8: return 40000 diff --git a/precompiles/package.json b/precompiles/package.json index 772e03a..8a34e27 100644 --- a/precompiles/package.json +++ b/precompiles/package.json @@ -8,7 +8,9 @@ }, "devDependencies": { "hardhat": "^2.19.3", + "rimraf": "^6.0.1", "ts-node": "10.9.2", + "typechain": "^8.3.2", "typescript": "4.9.5" }, "files": [ diff --git a/precompiles/pnpm-lock.yaml b/precompiles/pnpm-lock.yaml index 8794ecb..d45ea17 100644 --- a/precompiles/pnpm-lock.yaml +++ b/precompiles/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -8,9 +8,15 @@ devDependencies: hardhat: specifier: ^2.19.3 version: 2.19.3(ts-node@10.9.2)(typescript@4.9.5) + rimraf: + specifier: ^6.0.1 + version: 6.0.1 ts-node: specifier: 10.9.2 version: 10.9.2(@types/node@20.10.6)(typescript@4.9.5) + typechain: + specifier: ^8.3.2 + version: 8.3.2(typescript@4.9.5) typescript: specifier: 4.9.5 version: 4.9.5 @@ -375,6 +381,18 @@ packages: engines: {node: '>=14'} dev: true + /@isaacs/cliui@8.0.2: + resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} + engines: {node: '>=12'} + dependencies: + string-width: 5.1.2 + string-width-cjs: /string-width@4.2.3 + strip-ansi: 7.1.0 + strip-ansi-cjs: /strip-ansi@6.0.1 + wrap-ansi: 8.1.0 + wrap-ansi-cjs: /wrap-ansi@7.0.0 + dev: true + /@jridgewell/resolve-uri@3.1.1: resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} engines: {node: '>=6.0.0'} @@ -674,6 +692,13 @@ packages: '@nomicfoundation/solidity-analyzer-win32-x64-msvc': 0.1.1 dev: true + /@pkgjs/parseargs@0.11.0: + resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} + engines: {node: '>=14'} + requiresBuild: true + dev: true + optional: true + /@scure/base@1.1.5: resolution: {integrity: sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==} dev: true @@ -807,6 +832,10 @@ packages: '@types/node': 20.10.6 dev: true + /@types/prettier@2.7.3: + resolution: {integrity: sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==} + dev: true + /@types/readable-stream@2.3.15: resolution: {integrity: sha512-oM5JSKQCcICF1wvGgmecmHldZ48OZamtMxcGGVICOJA8o8cahXC1zEVAif8iwoc5j8etxFaRFnf095+CDsuoFQ==} dependencies: @@ -892,6 +921,11 @@ packages: engines: {node: '>=8'} dev: true + /ansi-regex@6.1.0: + resolution: {integrity: sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==} + engines: {node: '>=12'} + dev: true + /ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} @@ -906,6 +940,11 @@ packages: color-convert: 2.0.1 dev: true + /ansi-styles@6.2.1: + resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} + engines: {node: '>=12'} + dev: true + /anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} engines: {node: '>= 8'} @@ -922,6 +961,16 @@ packages: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} dev: true + /array-back@3.1.0: + resolution: {integrity: sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==} + engines: {node: '>=6'} + dev: true + + /array-back@4.0.2: + resolution: {integrity: sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==} + engines: {node: '>=8'} + dev: true + /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true @@ -1152,6 +1201,26 @@ packages: resolution: {integrity: sha512-LTQ/SGc+s0Xc0Fu5WaKnR0YiygZkm9eKFvyS+fRsU7/ZWFF8ykFM6Pc9aCVf1+xasOOZpO3BAVgVrKvsqKHV7w==} dev: true + /command-line-args@5.2.1: + resolution: {integrity: sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==} + engines: {node: '>=4.0.0'} + dependencies: + array-back: 3.1.0 + find-replace: 3.0.0 + lodash.camelcase: 4.3.0 + typical: 4.0.0 + dev: true + + /command-line-usage@6.1.3: + resolution: {integrity: sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==} + engines: {node: '>=8.0.0'} + dependencies: + array-back: 4.0.2 + chalk: 2.4.2 + table-layout: 1.0.2 + typical: 5.2.0 + dev: true + /commander@3.0.2: resolution: {integrity: sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow==} dev: true @@ -1196,6 +1265,15 @@ packages: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} dev: true + /cross-spawn@7.0.3: + resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + engines: {node: '>= 8'} + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + dev: true + /debug@4.3.4(supports-color@8.1.1): resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} engines: {node: '>=6.0'} @@ -1214,6 +1292,11 @@ packages: engines: {node: '>=10'} dev: true + /deep-extend@0.6.0: + resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} + engines: {node: '>=4.0.0'} + dev: true + /depd@2.0.0: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} engines: {node: '>= 0.8'} @@ -1229,6 +1312,10 @@ packages: engines: {node: '>=0.3.1'} dev: true + /eastasianwidth@0.2.0: + resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + dev: true + /elliptic@6.5.4: resolution: {integrity: sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==} dependencies: @@ -1245,6 +1332,10 @@ packages: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true + /emoji-regex@9.2.2: + resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + dev: true + /enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -1381,6 +1472,13 @@ packages: to-regex-range: 5.0.1 dev: true + /find-replace@3.0.0: + resolution: {integrity: sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==} + engines: {node: '>=4.0.0'} + dependencies: + array-back: 3.1.0 + dev: true + /find-up@2.1.0: resolution: {integrity: sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==} engines: {node: '>=4'} @@ -1413,6 +1511,14 @@ packages: debug: 4.3.4(supports-color@8.1.1) dev: true + /foreground-child@3.3.0: + resolution: {integrity: sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==} + engines: {node: '>=14'} + dependencies: + cross-spawn: 7.0.3 + signal-exit: 4.1.0 + dev: true + /fp-ts@1.19.3: resolution: {integrity: sha512-H5KQDspykdHuztLTg+ajGN0Z2qUjcEf3Ybxc6hLt0k7/zPkn29XnKnxlBPyW2XIddWrGaJBzBl4VLYOtk39yZg==} dev: true @@ -1464,6 +1570,31 @@ packages: is-glob: 4.0.3 dev: true + /glob@11.0.0: + resolution: {integrity: sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==} + engines: {node: 20 || >=22} + hasBin: true + dependencies: + foreground-child: 3.3.0 + jackspeak: 4.0.1 + minimatch: 10.0.1 + minipass: 7.1.2 + package-json-from-dist: 1.0.0 + path-scurry: 2.0.0 + dev: true + + /glob@7.1.7: + resolution: {integrity: sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==} + deprecated: Glob versions prior to v9 are no longer supported + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 3.1.2 + once: 1.4.0 + path-is-absolute: 1.0.1 + dev: true + /glob@7.2.0: resolution: {integrity: sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==} dependencies: @@ -1693,6 +1824,19 @@ packages: engines: {node: '>=10'} dev: true + /isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + dev: true + + /jackspeak@4.0.1: + resolution: {integrity: sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==} + engines: {node: 20 || >=22} + dependencies: + '@isaacs/cliui': 8.0.2 + optionalDependencies: + '@pkgjs/parseargs': 0.11.0 + dev: true + /js-sdsl@4.4.2: resolution: {integrity: sha512-dwXFwByc/ajSV6m5bcKAPwe4yDDF6D614pxmIi5odytzxRlwqF6nwoiCek80Ixc7Cvma5awClxrzFtxCQvcM8w==} dev: true @@ -1772,6 +1916,10 @@ packages: p-locate: 5.0.0 dev: true + /lodash.camelcase@4.3.0: + resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} + dev: true + /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: true @@ -1784,6 +1932,11 @@ packages: is-unicode-supported: 0.1.0 dev: true + /lru-cache@11.0.1: + resolution: {integrity: sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==} + engines: {node: 20 || >=22} + dev: true + /lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} dependencies: @@ -1833,6 +1986,13 @@ packages: resolution: {integrity: sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==} dev: true + /minimatch@10.0.1: + resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} + engines: {node: 20 || >=22} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimatch@3.1.2: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: @@ -1846,6 +2006,17 @@ packages: brace-expansion: 2.0.1 dev: true + /minipass@7.1.2: + resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==} + engines: {node: '>=16 || 14 >=14.17'} + dev: true + + /mkdirp@1.0.4: + resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} + engines: {node: '>=10'} + hasBin: true + dev: true + /mnemonist@0.38.5: resolution: {integrity: sha512-bZTFT5rrPKtPJxj8KSV0WkPyNxl72vQepqqVUAW2ARUpUSF2qXMB6jZj7hW5/k7C1rtpzqbD/IIbJwLXUjCHeg==} dependencies: @@ -1972,6 +2143,10 @@ packages: engines: {node: '>=4'} dev: true + /package-json-from-dist@1.0.0: + resolution: {integrity: sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==} + dev: true + /path-exists@3.0.0: resolution: {integrity: sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==} engines: {node: '>=4'} @@ -1987,10 +2162,23 @@ packages: engines: {node: '>=0.10.0'} dev: true + /path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + dev: true + /path-parse@1.0.7: resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} dev: true + /path-scurry@2.0.0: + resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} + engines: {node: 20 || >=22} + dependencies: + lru-cache: 11.0.1 + minipass: 7.1.2 + dev: true + /pbkdf2@3.1.2: resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==} engines: {node: '>=0.12'} @@ -2007,6 +2195,12 @@ packages: engines: {node: '>=8.6'} dev: true + /prettier@2.8.8: + resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} + engines: {node: '>=10.13.0'} + hasBin: true + dev: true + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -2043,6 +2237,11 @@ packages: picomatch: 2.3.1 dev: true + /reduce-flatten@2.0.0: + resolution: {integrity: sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==} + engines: {node: '>=6'} + dev: true + /require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -2061,11 +2260,21 @@ packages: /rimraf@2.7.1: resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true dependencies: glob: 7.2.0 dev: true + /rimraf@6.0.1: + resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} + engines: {node: 20 || >=22} + hasBin: true + dependencies: + glob: 11.0.0 + package-json-from-dist: 1.0.0 + dev: true + /ripemd160@2.0.2: resolution: {integrity: sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==} dependencies: @@ -2148,6 +2357,23 @@ packages: safe-buffer: 5.2.1 dev: true + /shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + dependencies: + shebang-regex: 3.0.0 + dev: true + + /shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + dev: true + + /signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + dev: true + /solc@0.7.3(debug@4.3.4): resolution: {integrity: sha512-GAsWNAjGzIDg7VxzP6mPjdurby3IkGCjQcM8GFYZT6RyaoUZKmMU6Y7YwG+tFGhv7dwZ8rmR4iwFDrrD99JwqA==} engines: {node: '>=8.0.0'} @@ -2190,6 +2416,10 @@ packages: engines: {node: '>= 0.8'} dev: true + /string-format@2.0.0: + resolution: {integrity: sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==} + dev: true + /string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -2199,6 +2429,15 @@ packages: strip-ansi: 6.0.1 dev: true + /string-width@5.1.2: + resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==} + engines: {node: '>=12'} + dependencies: + eastasianwidth: 0.2.0 + emoji-regex: 9.2.2 + strip-ansi: 7.1.0 + dev: true + /string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} dependencies: @@ -2212,6 +2451,13 @@ packages: ansi-regex: 5.0.1 dev: true + /strip-ansi@7.1.0: + resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} + engines: {node: '>=12'} + dependencies: + ansi-regex: 6.1.0 + dev: true + /strip-hex-prefix@1.0.0: resolution: {integrity: sha512-q8d4ue7JGEiVcypji1bALTos+0pWtyGlivAWyPuTkHzuTCJqrK9sWxYQZUq6Nq3cuyv3bm734IhHvHtGGURU6A==} engines: {node: '>=6.5.0', npm: '>=3'} @@ -2245,6 +2491,16 @@ packages: has-flag: 4.0.0 dev: true + /table-layout@1.0.2: + resolution: {integrity: sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==} + engines: {node: '>=8.0.0'} + dependencies: + array-back: 4.0.2 + deep-extend: 0.6.0 + typical: 5.2.0 + wordwrapjs: 4.0.1 + dev: true + /tmp@0.0.33: resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} engines: {node: '>=0.6.0'} @@ -2264,6 +2520,24 @@ packages: engines: {node: '>=0.6'} dev: true + /ts-command-line-args@2.5.1: + resolution: {integrity: sha512-H69ZwTw3rFHb5WYpQya40YAX2/w7Ut75uUECbgBIsLmM+BNuYnxsltfyyLMxy6sEeKxgijLTnQtLd0nKd6+IYw==} + hasBin: true + dependencies: + chalk: 4.1.2 + command-line-args: 5.2.1 + command-line-usage: 6.1.3 + string-format: 2.0.0 + dev: true + + /ts-essentials@7.0.3(typescript@4.9.5): + resolution: {integrity: sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==} + peerDependencies: + typescript: '>=3.7.0' + dependencies: + typescript: 4.9.5 + dev: true + /ts-node@10.9.2(@types/node@20.10.6)(typescript@4.9.5): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true @@ -2321,12 +2595,43 @@ packages: engines: {node: '>=8'} dev: true + /typechain@8.3.2(typescript@4.9.5): + resolution: {integrity: sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==} + hasBin: true + peerDependencies: + typescript: '>=4.3.0' + dependencies: + '@types/prettier': 2.7.3 + debug: 4.3.4(supports-color@8.1.1) + fs-extra: 7.0.1 + glob: 7.1.7 + js-sha3: 0.8.0 + lodash: 4.17.21 + mkdirp: 1.0.4 + prettier: 2.8.8 + ts-command-line-args: 2.5.1 + ts-essentials: 7.0.3(typescript@4.9.5) + typescript: 4.9.5 + transitivePeerDependencies: + - supports-color + dev: true + /typescript@4.9.5: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} hasBin: true dev: true + /typical@4.0.0: + resolution: {integrity: sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==} + engines: {node: '>=8'} + dev: true + + /typical@5.2.0: + resolution: {integrity: sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==} + engines: {node: '>=8'} + dev: true + /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} dev: true @@ -2361,6 +2666,22 @@ packages: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} dev: true + /which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + dependencies: + isexe: 2.0.0 + dev: true + + /wordwrapjs@4.0.1: + resolution: {integrity: sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==} + engines: {node: '>=8.0.0'} + dependencies: + reduce-flatten: 2.0.0 + typical: 5.2.0 + dev: true + /workerpool@6.2.1: resolution: {integrity: sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==} dev: true @@ -2374,6 +2695,15 @@ packages: strip-ansi: 6.0.1 dev: true + /wrap-ansi@8.1.0: + resolution: {integrity: sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==} + engines: {node: '>=12'} + dependencies: + ansi-styles: 6.2.1 + string-width: 5.1.2 + strip-ansi: 7.1.0 + dev: true + /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true diff --git a/precompiles/types/types.go b/precompiles/types/types.go index 5912e2e..cb31341 100644 --- a/precompiles/types/types.go +++ b/precompiles/types/types.go @@ -71,6 +71,7 @@ const ( Random Rol Ror + Square ) var precompileNameToString = map[PrecompileName]string{ @@ -104,6 +105,7 @@ var precompileNameToString = map[PrecompileName]string{ TrivialEncrypt: "trivialEncrypt", Rol: "rol", Ror: "ror", + Square: "square", } var stringToPrecompileName = map[string]PrecompileName{ @@ -137,6 +139,7 @@ var stringToPrecompileName = map[string]PrecompileName{ "trivialEncrypt": TrivialEncrypt, "rol": Rol, "ror": Ror, + "square": Square, } func (pn PrecompileName) String() string { diff --git a/solgen/common.ts b/solgen/common.ts index 572392e..aa1f779 100644 --- a/solgen/common.ts +++ b/solgen/common.ts @@ -19,7 +19,7 @@ const patternAllowedOperationsEuint16 = [".*"]; const patternAllowedOperationsEuint32 = [".*"]; const patternAllowedOperationsEuint64 = ["^(?!div)", "^(?!rem)"]; -const patternAllowedOperationsEuint128 = ["^(?!div)", "^(?!rem)", "^(?!mul)"]; +const patternAllowedOperationsEuint128 = ["^(?!div)", "^(?!rem)", "^(?!mul)", "^(?!square)"]; const patternAllowedOperationsEuint256 = ["ne|eq|sealoutput|select|seal|decrypt|random"]; const patternAllowedOperationsEaddress = ["ne|^eq$|sealoutput|select|seal|decrypt"]; @@ -242,6 +242,12 @@ export const ShorthandOperations: OperatorMap[] = [ unary: false, returnsBool: false, }, + // { + // func: "square", + // operator: null, + // unary: false, + // returnsBool: false, + // }, ]; export const BindMathOperators = [ @@ -251,6 +257,7 @@ export const BindMathOperators = [ "sub", "eq", "ne", + "not", "and", "or", "xor", @@ -264,7 +271,8 @@ export const BindMathOperators = [ "shl", "shr", "rol", - "ror" + "ror", + "square", ]; export const bitwiseAndLogicalOperators = ["and", "or", "xor", "not"]; diff --git a/solgen/templates/library.ts b/solgen/templates/library.ts index 959845f..eb990e7 100644 --- a/solgen/templates/library.ts +++ b/solgen/templates/library.ts @@ -748,7 +748,7 @@ export const OperatorBinding = ( /// @param lhs input of type ${forType} `; - if (unary) { + if (!unary) { docString += `/// @param rhs second input of type ${forType}\n`; } diff --git a/solgen/templates/testContracts.ts b/solgen/templates/testContracts.ts index 747ffe5..9a0eef4 100644 --- a/solgen/templates/testContracts.ts +++ b/solgen/templates/testContracts.ts @@ -353,6 +353,10 @@ export function testContract1Arg(name: string) { name, EInputType.indexOf("euint256") ); + const isEboolAllowed = IsOperationAllowed( + name, + EInputType.indexOf("ebool") + ); let func = `function ${name}(string calldata test, uint256 a, int32 securityZone) public pure returns (uint256 output) { if (Utils.cmp(test, "${name}(euint8)")) { return FHE.decrypt(FHE.${name}(FHE.asEuint8(a, securityZone))); @@ -376,7 +380,8 @@ export function testContract1Arg(name: string) { return FHE.decrypt(FHE.${name}(FHE.asEuint256(a, securityZone))); }`; } - func += ` else if (Utils.cmp(test, "${name}(ebool)")) { + if(isEboolAllowed) { + func += ` else if (Utils.cmp(test, "${name}(ebool)")) { bool aBool = true; if (a == 0) { aBool = false; @@ -387,7 +392,31 @@ export function testContract1Arg(name: string) { } return 0; - } + }`; + } + func += ` else if (Utils.cmp(test, "euint8.${name}()")) { + return FHE.decrypt(FHE.asEuint8(a, securityZone).${name}()); + } else if (Utils.cmp(test, "euint16.${name}()")) { + return FHE.decrypt(FHE.asEuint16(a, securityZone).${name}()); + } else if (Utils.cmp(test, "euint32.${name}()")) { + return FHE.decrypt(FHE.asEuint32(a, securityZone).${name}()); + }`; + if (isEuint64Allowed) { + func += ` else if (Utils.cmp(test, "euint64.${name}()")) { + return FHE.decrypt(FHE.asEuint64(a, securityZone).${name}()); + }`; + } + if (isEuint128Allowed) { + func += ` else if (Utils.cmp(test, "euint128.${name}()")) { + return FHE.decrypt(FHE.asEuint128(a, securityZone).${name}()); + }`; + } + if (isEuint256Allowed) { + func += ` else if (Utils.cmp(test, "euint256.${name}()")) { + return FHE.decrypt(FHE.asEuint256(a, securityZone).${name}()); + }`; + } + func += ` revert TestNotFound(test); }`; diff --git a/solidity/FHE.sol b/solidity/FHE.sol index 5fe69fe..3e872bc 100644 --- a/solidity/FHE.sol +++ b/solidity/FHE.sol @@ -2788,6 +2788,58 @@ library FHE { uint256 result = Impl.getValue(b); return euint128.wrap(result); } + /// @notice Performs the square operation on a ciphertext + /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param input1 the input ciphertext + function square(euint8 input1) internal pure returns (euint8) { + if (!isInitialized(input1)) { + input1 = asEuint8(0); + } + uint256 unwrappedInput1 = euint8.unwrap(input1); + bytes memory inputAsBytes = Common.toBytes(unwrappedInput1); + bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT8_TFHE, inputAsBytes); + uint256 result = Impl.getValue(b); + return euint8.wrap(result); + } + /// @notice Performs the square operation on a ciphertext + /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param input1 the input ciphertext + function square(euint16 input1) internal pure returns (euint16) { + if (!isInitialized(input1)) { + input1 = asEuint16(0); + } + uint256 unwrappedInput1 = euint16.unwrap(input1); + bytes memory inputAsBytes = Common.toBytes(unwrappedInput1); + bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT16_TFHE, inputAsBytes); + uint256 result = Impl.getValue(b); + return euint16.wrap(result); + } + /// @notice Performs the square operation on a ciphertext + /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param input1 the input ciphertext + function square(euint32 input1) internal pure returns (euint32) { + if (!isInitialized(input1)) { + input1 = asEuint32(0); + } + uint256 unwrappedInput1 = euint32.unwrap(input1); + bytes memory inputAsBytes = Common.toBytes(unwrappedInput1); + bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT32_TFHE, inputAsBytes); + uint256 result = Impl.getValue(b); + return euint32.wrap(result); + } + /// @notice Performs the square operation on a ciphertext + /// @dev Verifies that the input value matches a valid ciphertext. Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param input1 the input ciphertext + function square(euint64 input1) internal pure returns (euint64) { + if (!isInitialized(input1)) { + input1 = asEuint64(0); + } + uint256 unwrappedInput1 = euint64.unwrap(input1); + bytes memory inputAsBytes = Common.toBytes(unwrappedInput1); + bytes memory b = FheOps(Precompiles.Fheos).square(Common.EUINT64_TFHE, inputAsBytes); + uint256 result = Impl.getValue(b); + return euint64.wrap(result); + } /// @notice Generates a random value of a given type with the given seed, for the provided securityZone /// @dev Calls the desired precompile and returns the hash of the ciphertext /// @param uintType the type of the random value to generate @@ -3540,7 +3592,8 @@ library BindingsEbool { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type ebool - /// @return the result of the eq + /// @param rhs second input of type ebool +/// @return the result of the eq function eq(ebool lhs, ebool rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -3548,15 +3601,25 @@ library BindingsEbool { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type ebool - /// @return the result of the ne + /// @param rhs second input of type ebool +/// @return the result of the ne function ne(ebool lhs, ebool rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } + /// @notice Performs the not operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type ebool + /// @return the result of the not + function not(ebool lhs) internal pure returns (ebool) { + return FHE.not(lhs); + } + /// @notice Performs the and operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type ebool - /// @return the result of the and + /// @param rhs second input of type ebool +/// @return the result of the and function and(ebool lhs, ebool rhs) internal pure returns (ebool) { return FHE.and(lhs, rhs); } @@ -3564,7 +3627,8 @@ library BindingsEbool { /// @notice Performs the or operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type ebool - /// @return the result of the or + /// @param rhs second input of type ebool +/// @return the result of the or function or(ebool lhs, ebool rhs) internal pure returns (ebool) { return FHE.or(lhs, rhs); } @@ -3572,7 +3636,8 @@ library BindingsEbool { /// @notice Performs the xor operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type ebool - /// @return the result of the xor + /// @param rhs second input of type ebool +/// @return the result of the xor function xor(ebool lhs, ebool rhs) internal pure returns (ebool) { return FHE.xor(lhs, rhs); } @@ -3611,7 +3676,8 @@ library BindingsEuint8 { /// @notice Performs the add operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the add + /// @param rhs second input of type euint8 +/// @return the result of the add function add(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.add(lhs, rhs); } @@ -3619,7 +3685,8 @@ library BindingsEuint8 { /// @notice Performs the mul operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the mul + /// @param rhs second input of type euint8 +/// @return the result of the mul function mul(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.mul(lhs, rhs); } @@ -3627,7 +3694,8 @@ library BindingsEuint8 { /// @notice Performs the div operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the div + /// @param rhs second input of type euint8 +/// @return the result of the div function div(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.div(lhs, rhs); } @@ -3635,7 +3703,8 @@ library BindingsEuint8 { /// @notice Performs the sub operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the sub + /// @param rhs second input of type euint8 +/// @return the result of the sub function sub(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.sub(lhs, rhs); } @@ -3643,7 +3712,8 @@ library BindingsEuint8 { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the eq + /// @param rhs second input of type euint8 +/// @return the result of the eq function eq(euint8 lhs, euint8 rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -3651,15 +3721,25 @@ library BindingsEuint8 { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the ne + /// @param rhs second input of type euint8 +/// @return the result of the ne function ne(euint8 lhs, euint8 rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } + /// @notice Performs the not operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint8 + /// @return the result of the not + function not(euint8 lhs) internal pure returns (euint8) { + return FHE.not(lhs); + } + /// @notice Performs the and operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the and + /// @param rhs second input of type euint8 +/// @return the result of the and function and(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.and(lhs, rhs); } @@ -3667,7 +3747,8 @@ library BindingsEuint8 { /// @notice Performs the or operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the or + /// @param rhs second input of type euint8 +/// @return the result of the or function or(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.or(lhs, rhs); } @@ -3675,7 +3756,8 @@ library BindingsEuint8 { /// @notice Performs the xor operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the xor + /// @param rhs second input of type euint8 +/// @return the result of the xor function xor(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.xor(lhs, rhs); } @@ -3683,7 +3765,8 @@ library BindingsEuint8 { /// @notice Performs the gt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the gt + /// @param rhs second input of type euint8 +/// @return the result of the gt function gt(euint8 lhs, euint8 rhs) internal pure returns (ebool) { return FHE.gt(lhs, rhs); } @@ -3691,7 +3774,8 @@ library BindingsEuint8 { /// @notice Performs the gte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the gte + /// @param rhs second input of type euint8 +/// @return the result of the gte function gte(euint8 lhs, euint8 rhs) internal pure returns (ebool) { return FHE.gte(lhs, rhs); } @@ -3699,7 +3783,8 @@ library BindingsEuint8 { /// @notice Performs the lt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the lt + /// @param rhs second input of type euint8 +/// @return the result of the lt function lt(euint8 lhs, euint8 rhs) internal pure returns (ebool) { return FHE.lt(lhs, rhs); } @@ -3707,7 +3792,8 @@ library BindingsEuint8 { /// @notice Performs the lte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the lte + /// @param rhs second input of type euint8 +/// @return the result of the lte function lte(euint8 lhs, euint8 rhs) internal pure returns (ebool) { return FHE.lte(lhs, rhs); } @@ -3715,7 +3801,8 @@ library BindingsEuint8 { /// @notice Performs the rem operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the rem + /// @param rhs second input of type euint8 +/// @return the result of the rem function rem(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.rem(lhs, rhs); } @@ -3723,7 +3810,8 @@ library BindingsEuint8 { /// @notice Performs the max operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the max + /// @param rhs second input of type euint8 +/// @return the result of the max function max(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.max(lhs, rhs); } @@ -3731,7 +3819,8 @@ library BindingsEuint8 { /// @notice Performs the min operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the min + /// @param rhs second input of type euint8 +/// @return the result of the min function min(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.min(lhs, rhs); } @@ -3739,7 +3828,8 @@ library BindingsEuint8 { /// @notice Performs the shl operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the shl + /// @param rhs second input of type euint8 +/// @return the result of the shl function shl(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.shl(lhs, rhs); } @@ -3747,7 +3837,8 @@ library BindingsEuint8 { /// @notice Performs the shr operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the shr + /// @param rhs second input of type euint8 +/// @return the result of the shr function shr(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.shr(lhs, rhs); } @@ -3755,7 +3846,8 @@ library BindingsEuint8 { /// @notice Performs the rol operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the rol + /// @param rhs second input of type euint8 +/// @return the result of the rol function rol(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.rol(lhs, rhs); } @@ -3763,10 +3855,19 @@ library BindingsEuint8 { /// @notice Performs the ror operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint8 - /// @return the result of the ror + /// @param rhs second input of type euint8 +/// @return the result of the ror function ror(euint8 lhs, euint8 rhs) internal pure returns (euint8) { return FHE.ror(lhs, rhs); } + + /// @notice Performs the square operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint8 + /// @return the result of the square + function square(euint8 lhs) internal pure returns (euint8) { + return FHE.square(lhs); + } function toBool(euint8 value) internal pure returns (ebool) { return FHE.asEbool(value); } @@ -3802,7 +3903,8 @@ library BindingsEuint16 { /// @notice Performs the add operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the add + /// @param rhs second input of type euint16 +/// @return the result of the add function add(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.add(lhs, rhs); } @@ -3810,7 +3912,8 @@ library BindingsEuint16 { /// @notice Performs the mul operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the mul + /// @param rhs second input of type euint16 +/// @return the result of the mul function mul(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.mul(lhs, rhs); } @@ -3818,7 +3921,8 @@ library BindingsEuint16 { /// @notice Performs the div operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the div + /// @param rhs second input of type euint16 +/// @return the result of the div function div(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.div(lhs, rhs); } @@ -3826,7 +3930,8 @@ library BindingsEuint16 { /// @notice Performs the sub operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the sub + /// @param rhs second input of type euint16 +/// @return the result of the sub function sub(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.sub(lhs, rhs); } @@ -3834,7 +3939,8 @@ library BindingsEuint16 { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the eq + /// @param rhs second input of type euint16 +/// @return the result of the eq function eq(euint16 lhs, euint16 rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -3842,15 +3948,25 @@ library BindingsEuint16 { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the ne + /// @param rhs second input of type euint16 +/// @return the result of the ne function ne(euint16 lhs, euint16 rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } + /// @notice Performs the not operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint16 + /// @return the result of the not + function not(euint16 lhs) internal pure returns (euint16) { + return FHE.not(lhs); + } + /// @notice Performs the and operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the and + /// @param rhs second input of type euint16 +/// @return the result of the and function and(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.and(lhs, rhs); } @@ -3858,7 +3974,8 @@ library BindingsEuint16 { /// @notice Performs the or operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the or + /// @param rhs second input of type euint16 +/// @return the result of the or function or(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.or(lhs, rhs); } @@ -3866,7 +3983,8 @@ library BindingsEuint16 { /// @notice Performs the xor operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the xor + /// @param rhs second input of type euint16 +/// @return the result of the xor function xor(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.xor(lhs, rhs); } @@ -3874,7 +3992,8 @@ library BindingsEuint16 { /// @notice Performs the gt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the gt + /// @param rhs second input of type euint16 +/// @return the result of the gt function gt(euint16 lhs, euint16 rhs) internal pure returns (ebool) { return FHE.gt(lhs, rhs); } @@ -3882,7 +4001,8 @@ library BindingsEuint16 { /// @notice Performs the gte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the gte + /// @param rhs second input of type euint16 +/// @return the result of the gte function gte(euint16 lhs, euint16 rhs) internal pure returns (ebool) { return FHE.gte(lhs, rhs); } @@ -3890,7 +4010,8 @@ library BindingsEuint16 { /// @notice Performs the lt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the lt + /// @param rhs second input of type euint16 +/// @return the result of the lt function lt(euint16 lhs, euint16 rhs) internal pure returns (ebool) { return FHE.lt(lhs, rhs); } @@ -3898,7 +4019,8 @@ library BindingsEuint16 { /// @notice Performs the lte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the lte + /// @param rhs second input of type euint16 +/// @return the result of the lte function lte(euint16 lhs, euint16 rhs) internal pure returns (ebool) { return FHE.lte(lhs, rhs); } @@ -3906,7 +4028,8 @@ library BindingsEuint16 { /// @notice Performs the rem operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the rem + /// @param rhs second input of type euint16 +/// @return the result of the rem function rem(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.rem(lhs, rhs); } @@ -3914,7 +4037,8 @@ library BindingsEuint16 { /// @notice Performs the max operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the max + /// @param rhs second input of type euint16 +/// @return the result of the max function max(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.max(lhs, rhs); } @@ -3922,7 +4046,8 @@ library BindingsEuint16 { /// @notice Performs the min operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the min + /// @param rhs second input of type euint16 +/// @return the result of the min function min(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.min(lhs, rhs); } @@ -3930,7 +4055,8 @@ library BindingsEuint16 { /// @notice Performs the shl operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the shl + /// @param rhs second input of type euint16 +/// @return the result of the shl function shl(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.shl(lhs, rhs); } @@ -3938,7 +4064,8 @@ library BindingsEuint16 { /// @notice Performs the shr operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the shr + /// @param rhs second input of type euint16 +/// @return the result of the shr function shr(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.shr(lhs, rhs); } @@ -3946,7 +4073,8 @@ library BindingsEuint16 { /// @notice Performs the rol operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the rol + /// @param rhs second input of type euint16 +/// @return the result of the rol function rol(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.rol(lhs, rhs); } @@ -3954,10 +4082,19 @@ library BindingsEuint16 { /// @notice Performs the ror operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint16 - /// @return the result of the ror + /// @param rhs second input of type euint16 +/// @return the result of the ror function ror(euint16 lhs, euint16 rhs) internal pure returns (euint16) { return FHE.ror(lhs, rhs); } + + /// @notice Performs the square operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint16 + /// @return the result of the square + function square(euint16 lhs) internal pure returns (euint16) { + return FHE.square(lhs); + } function toBool(euint16 value) internal pure returns (ebool) { return FHE.asEbool(value); } @@ -3993,7 +4130,8 @@ library BindingsEuint32 { /// @notice Performs the add operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the add + /// @param rhs second input of type euint32 +/// @return the result of the add function add(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.add(lhs, rhs); } @@ -4001,7 +4139,8 @@ library BindingsEuint32 { /// @notice Performs the mul operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the mul + /// @param rhs second input of type euint32 +/// @return the result of the mul function mul(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.mul(lhs, rhs); } @@ -4009,7 +4148,8 @@ library BindingsEuint32 { /// @notice Performs the div operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the div + /// @param rhs second input of type euint32 +/// @return the result of the div function div(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.div(lhs, rhs); } @@ -4017,7 +4157,8 @@ library BindingsEuint32 { /// @notice Performs the sub operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the sub + /// @param rhs second input of type euint32 +/// @return the result of the sub function sub(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.sub(lhs, rhs); } @@ -4025,7 +4166,8 @@ library BindingsEuint32 { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the eq + /// @param rhs second input of type euint32 +/// @return the result of the eq function eq(euint32 lhs, euint32 rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -4033,15 +4175,25 @@ library BindingsEuint32 { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the ne + /// @param rhs second input of type euint32 +/// @return the result of the ne function ne(euint32 lhs, euint32 rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } + /// @notice Performs the not operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint32 + /// @return the result of the not + function not(euint32 lhs) internal pure returns (euint32) { + return FHE.not(lhs); + } + /// @notice Performs the and operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the and + /// @param rhs second input of type euint32 +/// @return the result of the and function and(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.and(lhs, rhs); } @@ -4049,7 +4201,8 @@ library BindingsEuint32 { /// @notice Performs the or operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the or + /// @param rhs second input of type euint32 +/// @return the result of the or function or(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.or(lhs, rhs); } @@ -4057,7 +4210,8 @@ library BindingsEuint32 { /// @notice Performs the xor operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the xor + /// @param rhs second input of type euint32 +/// @return the result of the xor function xor(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.xor(lhs, rhs); } @@ -4065,7 +4219,8 @@ library BindingsEuint32 { /// @notice Performs the gt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the gt + /// @param rhs second input of type euint32 +/// @return the result of the gt function gt(euint32 lhs, euint32 rhs) internal pure returns (ebool) { return FHE.gt(lhs, rhs); } @@ -4073,7 +4228,8 @@ library BindingsEuint32 { /// @notice Performs the gte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the gte + /// @param rhs second input of type euint32 +/// @return the result of the gte function gte(euint32 lhs, euint32 rhs) internal pure returns (ebool) { return FHE.gte(lhs, rhs); } @@ -4081,7 +4237,8 @@ library BindingsEuint32 { /// @notice Performs the lt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the lt + /// @param rhs second input of type euint32 +/// @return the result of the lt function lt(euint32 lhs, euint32 rhs) internal pure returns (ebool) { return FHE.lt(lhs, rhs); } @@ -4089,7 +4246,8 @@ library BindingsEuint32 { /// @notice Performs the lte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the lte + /// @param rhs second input of type euint32 +/// @return the result of the lte function lte(euint32 lhs, euint32 rhs) internal pure returns (ebool) { return FHE.lte(lhs, rhs); } @@ -4097,7 +4255,8 @@ library BindingsEuint32 { /// @notice Performs the rem operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the rem + /// @param rhs second input of type euint32 +/// @return the result of the rem function rem(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.rem(lhs, rhs); } @@ -4105,7 +4264,8 @@ library BindingsEuint32 { /// @notice Performs the max operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the max + /// @param rhs second input of type euint32 +/// @return the result of the max function max(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.max(lhs, rhs); } @@ -4113,7 +4273,8 @@ library BindingsEuint32 { /// @notice Performs the min operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the min + /// @param rhs second input of type euint32 +/// @return the result of the min function min(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.min(lhs, rhs); } @@ -4121,7 +4282,8 @@ library BindingsEuint32 { /// @notice Performs the shl operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the shl + /// @param rhs second input of type euint32 +/// @return the result of the shl function shl(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.shl(lhs, rhs); } @@ -4129,7 +4291,8 @@ library BindingsEuint32 { /// @notice Performs the shr operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the shr + /// @param rhs second input of type euint32 +/// @return the result of the shr function shr(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.shr(lhs, rhs); } @@ -4137,7 +4300,8 @@ library BindingsEuint32 { /// @notice Performs the rol operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the rol + /// @param rhs second input of type euint32 +/// @return the result of the rol function rol(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.rol(lhs, rhs); } @@ -4145,10 +4309,19 @@ library BindingsEuint32 { /// @notice Performs the ror operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint32 - /// @return the result of the ror + /// @param rhs second input of type euint32 +/// @return the result of the ror function ror(euint32 lhs, euint32 rhs) internal pure returns (euint32) { return FHE.ror(lhs, rhs); } + + /// @notice Performs the square operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint32 + /// @return the result of the square + function square(euint32 lhs) internal pure returns (euint32) { + return FHE.square(lhs); + } function toBool(euint32 value) internal pure returns (ebool) { return FHE.asEbool(value); } @@ -4184,7 +4357,8 @@ library BindingsEuint64 { /// @notice Performs the add operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the add + /// @param rhs second input of type euint64 +/// @return the result of the add function add(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.add(lhs, rhs); } @@ -4192,7 +4366,8 @@ library BindingsEuint64 { /// @notice Performs the mul operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the mul + /// @param rhs second input of type euint64 +/// @return the result of the mul function mul(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.mul(lhs, rhs); } @@ -4200,7 +4375,8 @@ library BindingsEuint64 { /// @notice Performs the sub operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the sub + /// @param rhs second input of type euint64 +/// @return the result of the sub function sub(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.sub(lhs, rhs); } @@ -4208,7 +4384,8 @@ library BindingsEuint64 { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the eq + /// @param rhs second input of type euint64 +/// @return the result of the eq function eq(euint64 lhs, euint64 rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -4216,15 +4393,25 @@ library BindingsEuint64 { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the ne + /// @param rhs second input of type euint64 +/// @return the result of the ne function ne(euint64 lhs, euint64 rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } + /// @notice Performs the not operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint64 + /// @return the result of the not + function not(euint64 lhs) internal pure returns (euint64) { + return FHE.not(lhs); + } + /// @notice Performs the and operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the and + /// @param rhs second input of type euint64 +/// @return the result of the and function and(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.and(lhs, rhs); } @@ -4232,7 +4419,8 @@ library BindingsEuint64 { /// @notice Performs the or operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the or + /// @param rhs second input of type euint64 +/// @return the result of the or function or(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.or(lhs, rhs); } @@ -4240,7 +4428,8 @@ library BindingsEuint64 { /// @notice Performs the xor operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the xor + /// @param rhs second input of type euint64 +/// @return the result of the xor function xor(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.xor(lhs, rhs); } @@ -4248,7 +4437,8 @@ library BindingsEuint64 { /// @notice Performs the gt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the gt + /// @param rhs second input of type euint64 +/// @return the result of the gt function gt(euint64 lhs, euint64 rhs) internal pure returns (ebool) { return FHE.gt(lhs, rhs); } @@ -4256,7 +4446,8 @@ library BindingsEuint64 { /// @notice Performs the gte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the gte + /// @param rhs second input of type euint64 +/// @return the result of the gte function gte(euint64 lhs, euint64 rhs) internal pure returns (ebool) { return FHE.gte(lhs, rhs); } @@ -4264,7 +4455,8 @@ library BindingsEuint64 { /// @notice Performs the lt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the lt + /// @param rhs second input of type euint64 +/// @return the result of the lt function lt(euint64 lhs, euint64 rhs) internal pure returns (ebool) { return FHE.lt(lhs, rhs); } @@ -4272,7 +4464,8 @@ library BindingsEuint64 { /// @notice Performs the lte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the lte + /// @param rhs second input of type euint64 +/// @return the result of the lte function lte(euint64 lhs, euint64 rhs) internal pure returns (ebool) { return FHE.lte(lhs, rhs); } @@ -4280,7 +4473,8 @@ library BindingsEuint64 { /// @notice Performs the max operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the max + /// @param rhs second input of type euint64 +/// @return the result of the max function max(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.max(lhs, rhs); } @@ -4288,7 +4482,8 @@ library BindingsEuint64 { /// @notice Performs the min operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the min + /// @param rhs second input of type euint64 +/// @return the result of the min function min(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.min(lhs, rhs); } @@ -4296,7 +4491,8 @@ library BindingsEuint64 { /// @notice Performs the shl operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the shl + /// @param rhs second input of type euint64 +/// @return the result of the shl function shl(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.shl(lhs, rhs); } @@ -4304,7 +4500,8 @@ library BindingsEuint64 { /// @notice Performs the shr operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the shr + /// @param rhs second input of type euint64 +/// @return the result of the shr function shr(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.shr(lhs, rhs); } @@ -4312,7 +4509,8 @@ library BindingsEuint64 { /// @notice Performs the rol operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the rol + /// @param rhs second input of type euint64 +/// @return the result of the rol function rol(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.rol(lhs, rhs); } @@ -4320,10 +4518,19 @@ library BindingsEuint64 { /// @notice Performs the ror operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint64 - /// @return the result of the ror + /// @param rhs second input of type euint64 +/// @return the result of the ror function ror(euint64 lhs, euint64 rhs) internal pure returns (euint64) { return FHE.ror(lhs, rhs); } + + /// @notice Performs the square operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint64 + /// @return the result of the square + function square(euint64 lhs) internal pure returns (euint64) { + return FHE.square(lhs); + } function toBool(euint64 value) internal pure returns (ebool) { return FHE.asEbool(value); } @@ -4359,7 +4566,8 @@ library BindingsEuint128 { /// @notice Performs the add operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the add + /// @param rhs second input of type euint128 +/// @return the result of the add function add(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.add(lhs, rhs); } @@ -4367,7 +4575,8 @@ library BindingsEuint128 { /// @notice Performs the sub operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the sub + /// @param rhs second input of type euint128 +/// @return the result of the sub function sub(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.sub(lhs, rhs); } @@ -4375,7 +4584,8 @@ library BindingsEuint128 { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the eq + /// @param rhs second input of type euint128 +/// @return the result of the eq function eq(euint128 lhs, euint128 rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -4383,15 +4593,25 @@ library BindingsEuint128 { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the ne + /// @param rhs second input of type euint128 +/// @return the result of the ne function ne(euint128 lhs, euint128 rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } + /// @notice Performs the not operation + /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access + /// @param lhs input of type euint128 + /// @return the result of the not + function not(euint128 lhs) internal pure returns (euint128) { + return FHE.not(lhs); + } + /// @notice Performs the and operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the and + /// @param rhs second input of type euint128 +/// @return the result of the and function and(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.and(lhs, rhs); } @@ -4399,7 +4619,8 @@ library BindingsEuint128 { /// @notice Performs the or operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the or + /// @param rhs second input of type euint128 +/// @return the result of the or function or(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.or(lhs, rhs); } @@ -4407,7 +4628,8 @@ library BindingsEuint128 { /// @notice Performs the xor operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the xor + /// @param rhs second input of type euint128 +/// @return the result of the xor function xor(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.xor(lhs, rhs); } @@ -4415,7 +4637,8 @@ library BindingsEuint128 { /// @notice Performs the gt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the gt + /// @param rhs second input of type euint128 +/// @return the result of the gt function gt(euint128 lhs, euint128 rhs) internal pure returns (ebool) { return FHE.gt(lhs, rhs); } @@ -4423,7 +4646,8 @@ library BindingsEuint128 { /// @notice Performs the gte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the gte + /// @param rhs second input of type euint128 +/// @return the result of the gte function gte(euint128 lhs, euint128 rhs) internal pure returns (ebool) { return FHE.gte(lhs, rhs); } @@ -4431,7 +4655,8 @@ library BindingsEuint128 { /// @notice Performs the lt operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the lt + /// @param rhs second input of type euint128 +/// @return the result of the lt function lt(euint128 lhs, euint128 rhs) internal pure returns (ebool) { return FHE.lt(lhs, rhs); } @@ -4439,7 +4664,8 @@ library BindingsEuint128 { /// @notice Performs the lte operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the lte + /// @param rhs second input of type euint128 +/// @return the result of the lte function lte(euint128 lhs, euint128 rhs) internal pure returns (ebool) { return FHE.lte(lhs, rhs); } @@ -4447,7 +4673,8 @@ library BindingsEuint128 { /// @notice Performs the max operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the max + /// @param rhs second input of type euint128 +/// @return the result of the max function max(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.max(lhs, rhs); } @@ -4455,7 +4682,8 @@ library BindingsEuint128 { /// @notice Performs the min operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the min + /// @param rhs second input of type euint128 +/// @return the result of the min function min(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.min(lhs, rhs); } @@ -4463,7 +4691,8 @@ library BindingsEuint128 { /// @notice Performs the shl operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the shl + /// @param rhs second input of type euint128 +/// @return the result of the shl function shl(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.shl(lhs, rhs); } @@ -4471,7 +4700,8 @@ library BindingsEuint128 { /// @notice Performs the shr operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the shr + /// @param rhs second input of type euint128 +/// @return the result of the shr function shr(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.shr(lhs, rhs); } @@ -4479,7 +4709,8 @@ library BindingsEuint128 { /// @notice Performs the rol operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the rol + /// @param rhs second input of type euint128 +/// @return the result of the rol function rol(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.rol(lhs, rhs); } @@ -4487,7 +4718,8 @@ library BindingsEuint128 { /// @notice Performs the ror operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint128 - /// @return the result of the ror + /// @param rhs second input of type euint128 +/// @return the result of the ror function ror(euint128 lhs, euint128 rhs) internal pure returns (euint128) { return FHE.ror(lhs, rhs); } @@ -4526,7 +4758,8 @@ library BindingsEuint256 { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint256 - /// @return the result of the eq + /// @param rhs second input of type euint256 +/// @return the result of the eq function eq(euint256 lhs, euint256 rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -4534,7 +4767,8 @@ library BindingsEuint256 { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type euint256 - /// @return the result of the ne + /// @param rhs second input of type euint256 +/// @return the result of the ne function ne(euint256 lhs, euint256 rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } @@ -4576,7 +4810,8 @@ library BindingsEaddress { /// @notice Performs the eq operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type eaddress - /// @return the result of the eq + /// @param rhs second input of type eaddress +/// @return the result of the eq function eq(eaddress lhs, eaddress rhs) internal pure returns (ebool) { return FHE.eq(lhs, rhs); } @@ -4584,7 +4819,8 @@ library BindingsEaddress { /// @notice Performs the ne operation /// @dev Pure in this function is marked as a hack/workaround - note that this function is NOT pure as fetches of ciphertexts require state access /// @param lhs input of type eaddress - /// @return the result of the ne + /// @param rhs second input of type eaddress +/// @return the result of the ne function ne(eaddress lhs, eaddress rhs) internal pure returns (ebool) { return FHE.ne(lhs, rhs); } diff --git a/solidity/FheOS.sol b/solidity/FheOS.sol index fc53e98..709105b 100644 --- a/solidity/FheOS.sol +++ b/solidity/FheOS.sol @@ -39,4 +39,5 @@ interface FheOps { function not(uint8 utype, bytes memory value) external pure returns (bytes memory); function random(uint8 utype, uint64 seed, int32 securityZone) external pure returns (bytes memory); function getNetworkPublicKey(int32 securityZone) external pure returns (bytes memory); + function square(uint8 utype, bytes memory value) external pure returns (bytes memory); } \ No newline at end of file diff --git a/solidity/package.json b/solidity/package.json index f23c94f..2734739 100644 --- a/solidity/package.json +++ b/solidity/package.json @@ -50,6 +50,7 @@ }, "scripts": { "test": "jest --runInBand", + "test:specific": "jest --runInBand -t", "compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile" } } diff --git a/solidity/tests/abis.ts b/solidity/tests/abis.ts index 23bd0ab..ac21c70 100644 --- a/solidity/tests/abis.ts +++ b/solidity/tests/abis.ts @@ -83,6 +83,9 @@ export interface NotTestType extends BaseContract { export interface RandomTestType extends BaseContract { random: (test: string) => Promise; } +export interface SquareTestType extends BaseContract { + square: (test: string, a: bigint) => Promise; +} export interface AsEboolTestType extends BaseContract { castFromEuint8ToEbool: (val: bigint, test: string) => Promise; castFromEuint16ToEbool: (val: bigint, test: string) => Promise; diff --git a/solidity/tests/contracts/Not.sol b/solidity/tests/contracts/Not.sol index d353b36..54aa0e5 100644 --- a/solidity/tests/contracts/Not.sol +++ b/solidity/tests/contracts/Not.sol @@ -32,6 +32,16 @@ contract NotTest { } return 0; + } else if (Utils.cmp(test, "euint8.not()")) { + return FHE.decrypt(FHE.asEuint8(a, securityZone).not()); + } else if (Utils.cmp(test, "euint16.not()")) { + return FHE.decrypt(FHE.asEuint16(a, securityZone).not()); + } else if (Utils.cmp(test, "euint32.not()")) { + return FHE.decrypt(FHE.asEuint32(a, securityZone).not()); + } else if (Utils.cmp(test, "euint64.not()")) { + return FHE.decrypt(FHE.asEuint64(a, securityZone).not()); + } else if (Utils.cmp(test, "euint128.not()")) { + return FHE.decrypt(FHE.asEuint128(a, securityZone).not()); } revert TestNotFound(test); diff --git a/solidity/tests/contracts/Square.sol b/solidity/tests/contracts/Square.sol new file mode 100644 index 0000000..c51d1a3 --- /dev/null +++ b/solidity/tests/contracts/Square.sol @@ -0,0 +1,34 @@ +// This file is auto-generated by solgen/templates/testContracts.ts +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {FHE, euint8, euint16, euint32, euint64, euint128, euint256, ebool} from "../../FHE.sol"; +import {Utils} from "./utils/Utils.sol"; + +error TestNotFound(string test); + +contract SquareTest { + using Utils for *; + + function square(string calldata test, uint256 a, int32 securityZone) public pure returns (uint256 output) { + if (Utils.cmp(test, "square(euint8)")) { + return FHE.decrypt(FHE.square(FHE.asEuint8(a, securityZone))); + } else if (Utils.cmp(test, "square(euint16)")) { + return FHE.decrypt(FHE.square(FHE.asEuint16(a, securityZone))); + } else if (Utils.cmp(test, "square(euint32)")) { + return FHE.decrypt(FHE.square(FHE.asEuint32(a, securityZone))); + } else if (Utils.cmp(test, "square(euint64)")) { + return FHE.decrypt(FHE.square(FHE.asEuint64(a, securityZone))); + } else if (Utils.cmp(test, "euint8.square()")) { + return FHE.decrypt(FHE.asEuint8(a, securityZone).square()); + } else if (Utils.cmp(test, "euint16.square()")) { + return FHE.decrypt(FHE.asEuint16(a, securityZone).square()); + } else if (Utils.cmp(test, "euint32.square()")) { + return FHE.decrypt(FHE.asEuint32(a, securityZone).square()); + } else if (Utils.cmp(test, "euint64.square()")) { + return FHE.decrypt(FHE.asEuint64(a, securityZone).square()); + } + + revert TestNotFound(test); + } +} diff --git a/solidity/tests/contracts/bench/Square.sol b/solidity/tests/contracts/bench/Square.sol new file mode 100644 index 0000000..28614cf --- /dev/null +++ b/solidity/tests/contracts/bench/Square.sol @@ -0,0 +1,44 @@ +// This file is auto-generated by solgen/templates/benchContracts.ts +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.17; + +import {FHE} from "../../../FHE.sol"; +import { + euint8, inEuint8, + euint16, inEuint16, + euint32, inEuint32, + euint64, inEuint64 +} from "../../../FHE.sol"; + +contract SquareBench { + euint8 internal a8; + euint16 internal a16; + euint32 internal a32; + euint64 internal a64; + + function load8(inEuint8 calldata _a) public { + a8 = FHE.asEuint8(_a); + } + function load16(inEuint16 calldata _a) public { + a16 = FHE.asEuint16(_a); + } + function load32(inEuint32 calldata _a) public { + a32 = FHE.asEuint32(_a); + } + function load64(inEuint64 calldata _a) public { + a64 = FHE.asEuint64(_a); + } + + function benchSquare8() public view { + FHE.square(a8); + } + function benchSquare16() public view { + FHE.square(a16); + } + function benchSquare32() public view { + FHE.square(a32); + } + function benchSquare64() public view { + FHE.square(a64); + } +} diff --git a/solidity/tests/precompiles.test.ts b/solidity/tests/precompiles.test.ts index 1212a92..5116657 100644 --- a/solidity/tests/precompiles.test.ts +++ b/solidity/tests/precompiles.test.ts @@ -33,7 +33,8 @@ import { AsEuint256TestType, AsEaddressTestType, RolTestType, - RorTestType + RorTestType, + SquareTestType, } from "./abis"; const getFheContract = async (contractAddress: string) => { @@ -1629,10 +1630,10 @@ describe("Test Ror", () => { BigInt(testCase.a), BigInt(testCase.b) ); - + expect(decryptedResult).toBe(BigInt(testCase.expectedResult)); }); - } + } } }); }); @@ -2650,3 +2651,83 @@ describe("Test AsEaddress", () => { expect(decimal).toBe(value); }); }); + +describe("Test Square", () => { + const overflow8 = 2 ** 4; + const overflow16 = 2 ** 8; + const overflow32 = 2 ** 16; + const overflow64 = 2 ** 32; + let contract; + + // We don't really need it as test but it is a test since it is async + it(`Test Contract Deployment`, async () => { + contract = (await deployContract("SquareTest")) as SquareTestType; + expect(contract).toBeTruthy(); + }); + + const testCases = [ + { + function: ["square(euint8)", "euint8.square()"], + cases: [ + { a: 2, expectedResult: 4, name: "" }, + { + a: overflow8, + expectedResult: Number(BigInt.asUintN(8, BigInt(overflow8 * overflow8))), + name: " as overflow", + }, + ], + }, + { + function: ["square(euint16)", "euint16.square()"], + cases: [ + { a: 2, expectedResult: 4, name: "" }, + { + a: overflow16, + expectedResult: Number(BigInt.asUintN(16, BigInt(overflow16 * overflow16))), + name: " as overflow", + }, + ], + }, + { + function: ["square(euint32)", "euint32.square()"], + cases: [ + { a: 2, expectedResult: 4, name: "" }, + { + a: overflow32, + b: 2, + expectedResult: Number(BigInt.asUintN(32, BigInt(overflow32 * overflow32))), + name: " as overflow", + }, + ], + }, + { + function: ["square(euint64)", "euint64.square()"], + cases: [ + { a: 3, expectedResult: 9, name: "" }, + { + a: overflow64, + expectedResult: Number(BigInt.asUintN(64, BigInt(overflow64 * overflow64))), + name: " with large number", + }, + ], + }, + ]; + + for (const test of testCases) { + for (const securityZone of [0]) { + for (const testFunc of test.function) { + for (const testCase of test.cases) { + it(`Test ${testFunc}${testCase.name} - security zone ${securityZone}`, async () => { + const decryptedResult = await contract.square( + testFunc, + BigInt(testCase.a), + securityZone + ); + expect(decryptedResult).toBe(BigInt(testCase.expectedResult)); + }); + } + } + } + } +}); +