From f32aaef5764c70d16bd632c4f720290048d6bae9 Mon Sep 17 00:00:00 2001 From: memosr Date: Sat, 8 Aug 2026 23:41:41 +0300 Subject: [PATCH] fix(tutorials): make ACL usage examples compile All 7 Solidity snippets in tutorials/acl-usage-examples.mdx fail to compile with solc 0.8.28 and cofhe-contracts@0.1.4. Three issues: - InEuint32 is a struct (ICofhe.sol), so parameters need an explicit data location (TypeError 6651, 9 occurrences) - Several functions have no visibility specifier (SyntaxError 4937) - Three state variables put private before the type, which is a ParserError (9182) that masked further errors in two blocks The documented API surface itself is correct: allowThis, allow, allowTransient, allowPublic and allowSender all exist in cofhe-contracts@0.1.4. Only the Solidity syntax is fixed here. --- tutorials/acl-usage-examples.mdx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tutorials/acl-usage-examples.mdx b/tutorials/acl-usage-examples.mdx index 1c726be..21d0944 100644 --- a/tutorials/acl-usage-examples.mdx +++ b/tutorials/acl-usage-examples.mdx @@ -23,7 +23,7 @@ The contract that creates the value for the first time will automatically get ow ```solidity // Contract A -function doAdd(InEuint32 input1, InEuint32 input2) { +function doAdd(InEuint32 memory input1, InEuint32 memory input2) public { euint32 handle1 = FHE.asEuint32(input1); // Contract A gets temporary ownership of handle1 euint32 handle2 = FHE.asEuint32(input2); // Contract A gets temporary ownership of handle2 @@ -41,10 +41,10 @@ To use the results in other transactions, explicit ownership must be granted wit ```solidity contract A { - private euint32 result; - private euint32 handle1; + euint32 private result; + euint32 private handle1; - function doAdd(InEuint32 input1, InEuint32 input2) { + function doAdd(InEuint32 memory input1, InEuint32 memory input2) public { handle1 = FHE.asEuint32(input1); // Contract A gets temporary ownership of handle1 euint32 handle2 = FHE.asEuint32(input2); // Contract A gets temporary ownership of handle2 @@ -52,7 +52,7 @@ contract A { FHE.allowThis(result); // result is allowed for future transactions } - function doSomethingWithResult() { + function doSomethingWithResult() public { FHE.allowPublic(result); // Allowed — marks result as publicly decryptable FHE.add(handle1, result); // ACLNotAllowed (handle1 is not owned persistently) } @@ -69,9 +69,9 @@ To decrypt a ciphertext off-chain via the decryption network, the issuer must be ```solidity contract A { - private mapping(address => euint32) balances; + mapping(address => euint32) private balances; - function transfer(InEuint32 _amount, address to) { + function transfer(InEuint32 memory _amount, address to) public { euint32 amount = FHE.asEuint32(_amount); balances[msg.sender] = FHE.sub(balances[msg.sender], amount); @@ -97,7 +97,7 @@ You can also allow other contracts to use your ciphertexts, either persistently ```solidity contract A { - function doAdd(InEuint32 input1) { + function doAdd(InEuint32 memory input1) public { euint32 handle1 = FHE.asEuint32(input1); // Contract A gets temporary ownership of handle1 FHE.allowTransient(handle1, addressB); // Contract B is allowed to use handle1 in this transaction alone @@ -120,7 +120,7 @@ Use `FHE.allowTransient()` when you only need to grant access for a single trans When modifying encrypted values that users need to access: ```solidity -function updateBalance(address user, InEuint32 amount) public { +function updateBalance(address user, InEuint32 memory amount) public { euint32 encryptedAmount = FHE.asEuint32(amount); balances[user] = FHE.add(balances[user], encryptedAmount); @@ -137,7 +137,7 @@ function updateBalance(address user, InEuint32 amount) public { A common pattern is to allow the message sender: ```solidity -function submitEncryptedData(InEuint32 data) public { +function submitEncryptedData(InEuint32 memory data) public { euint32 encryptedData = FHE.asEuint32(data); storedData[msg.sender] = encryptedData; @@ -151,7 +151,7 @@ function submitEncryptedData(InEuint32 data) public { For values that should be accessible to everyone: ```solidity -function setPublicValue(InEuint32 value) public onlyOwner { +function setPublicValue(InEuint32 memory value) public onlyOwner { publicValue = FHE.asEuint32(value); FHE.allowPublic(publicValue); // Everyone can now access this value }