---
# System prepended metadata

title: 'NFTs on Oasis Sapphire: Secret Data Standard'

---

# NFTs on Sapphire: Secret Data Standard?

Version 1

-----

## Secret Data

 There is an interface, `IPrivateData`:
 
  - `secret(bytes32 item, bytes32[] propertyName, bytes[] memory extra) external view returns (bytes32[]);`
    - Reverts the `item` or any `propertyName` + `extra` pairs are:
      - Not found,
      - Invalid,
      - Otherwise Inaccessible.
    - Otherwise, it returns the 32 byte value requested per property.
    - `extra` parameter allows for arbitrary authentication data to be passed.
  - `secretNames(bytes32 item, uint256 offset) external view returns (bytes32[16]);`
    - Retrieves the list of property names for an item, 16 at a time
    - Reverts if `offset*16 >= nIems`
  - `secretIsVoid(bytes32 item) external view returns (bool);`
    - Reverts if `item` is not found, invalid or otherwise inaccessible.
    - Returns `true` if the item is currently void
  
### Semantics

 Implementations must support the the ERC-165 `supportsInterface` function, contracts choose to implement any of the methods above deemed necessary.
 
 All functions must be called via `staticcall`, they must not mutate state.

 The functions should use a constant amount of gas before reverting.

 Each contract determines the meaning of the 'void' status:
 
  - Some properties may only be accessible if it's in the void state.
  - Others will only be accessible if it hasn't been voided.
 
 Being void is similar to scratching a lotto card, the genie has been let out of the bottle, it may still hold secret data but an owner has seen it.
 
 The void status cannot be cached without contract-specific logic, as some may 'un-void' items.
  
 A contract may have/manage many items which have many properties (e.g. NFTs)

-----

## Example Skeleton

In this example the IPrivateData interface is implemented by the contract which owns the data, it is possible for a contract to manage private properties for other contracts if separation of concerns is needed.

```solidity
// SPDX-License-Identifier: Apache-2.0

pragma solidity ^0.8.0;

interface ERC165 {
    function supportsInterface(bytes4 interfaceID) external view returns (bool);
}

interface IPrivateData {
    function secret(bytes32 item, bytes32[] propertyName, bytes[] memory extra) external view returns (bytes32[]);
    function secretNames(bytes32 item, uint256 offset) external view returns (bytes32[16]);
    function secretIsVoid(bytes32 item) external view returns (bool);
}

contract SecretDataManager is IERC165, IPrivateData {
    function supportsInterface(bytes4 interfaceID) external view returns (bool) {
        return interfaceID == this.secretIsVoid.selector
            || interfaceID == this.secrets.selector
            || interfaceID == this.secret.selector;
    }

    function secret(bytes32 item, bytes32[] propertyName, bytes[] memory extra) external view returns (bytes32[]) {
    
    }

    function secrets(bytes32 item, uint256 offset) external view returns (bytes32[16]) {
        require( offset == 0 );
        return [
            keccak256(bytes("example"));
        ];
    }

    function secretIsVoid(bytes32 item) external view returns (bool) {

    }
}

```