Solidity API
ManufacturerRegistry
Registry for tracking and maintaining relevant info for Manufacturers. In order to make chips valid for the protocol, manufacturers must register their chips in enrollments. Each enrollment will be assigned an id, which must be referenced when adding chips to the registry. Enrollments have a merkle root of all chipIds (addresses) that are valid for the enrollment. Manufacturer's can be found in three states:
- Unregistered: manufacturers[_manufacturerId].registered = false. This is the default state for all manufacturers.
- Registered: manufacturers[_manufacturerId].registered = true && manufacturers[_manufacturerId].owner != address(0).
- Read-only: manufacturers[_manufacturerId].registered = true && manufacturers[_manufacturerId].owner == address(0). Once a manufacturerId has been put in this state it CANNOT leave it.
ManufacturerAdded
event ManufacturerAdded(bytes32 manufacturerId, address owner)
ManufacturerRemoved
event ManufacturerRemoved(bytes32 manufacturerId)
EnrollmentAdded
event EnrollmentAdded(bytes32 manufacturerId, bytes32 enrollmentId, bytes32 merkleRoot, address manufacturerCertSigner, address authModel, string chipValidationDataUri, string bootloaderApp, string chipModel)
ManufacturerOwnerUpdated
event ManufacturerOwnerUpdated(bytes32 manufacturerId, address newOwner)
EnrollmentInfo
struct EnrollmentInfo {
uint256 manufacturerId;
bytes32 merkleRoot;
address manufacturerCertSigner;
address authModel;
string chipValidationDataUri;
string bootloaderApp;
string chipModel;
}
ManufacturerInfo
struct ManufacturerInfo {
address owner;
bool registered;
bytes32[] enrollments;
uint256 nonce;
}
onlyManufacturer
modifier onlyManufacturer(bytes32 _manufacturerId)
enrollments
mapping(bytes32 => struct ManufacturerRegistry.EnrollmentInfo) enrollments
manufacturers
mapping(bytes32 => struct ManufacturerRegistry.ManufacturerInfo) manufacturers
constructor
constructor(address _governance) public
Constructor for ManufacturerRegistry. Sets owner to governance address.
Parameters
Name | Type | Description |
---|---|---|
_governance | address | Address of governance |
addChipEnrollment
function addChipEnrollment(bytes32 _manufacturerId, bytes32 _merkleRoot, address _certSigner, address _authModel, string _chipValidationDataUri, string _bootloaderApp, string _chipModel) external returns (bytes32 enrollmentId)
_ONLY MANUFACTURER: Adds a new enrollment for an active manufacturer. Enrollment is assigned an id which is returned. Only owner address associated with manufacturerId can call this function. An "active" manufacturer is one with registered=true and a non-zero owner address.
Parameters
Name | Type | Description |
---|---|---|
_manufacturerId | bytes32 | Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name) |
_merkleRoot | bytes32 | Merkle root of all chipIds (addresses) that are valid for this enrollment |
_certSigner | address | Address of certificate signer for this enrollment |
_authModel | address | Address of contract that implements example signature validation for a chip |
_chipValidationDataUri | string | URI pointing to location of off-chain data required to validate chip is part of manufacturer enrollment |
_bootloaderApp | string | Bootloader app for this enrollment |
_chipModel | string | Chip model for this enrollment |
Return Values
Name | Type | Description |
---|---|---|
enrollmentId | bytes32 | Id of enrollment |
addManufacturer
function addManufacturer(bytes32 _manufacturerId, address _owner) external
ONLY OWNER: Registers a new manufacturer. Manufacturer is marked as registered forever once added so that history can't be mixed with other manufacturers. To burn access the owner param is set to the zero address (in removeManufacturer). A manufacturer is considered "new" if registered=false.
Parameters
Name | Type | Description |
---|---|---|
_manufacturerId | bytes32 | Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name) |
_owner | address | Address of Perp Vault contract |
removeManufacturer
function removeManufacturer(bytes32 _manufacturerId) external
ONLY OWNER: Removes an active manufacturer putting their history in read-only mode. In order to remove access we burn the owner key, this prevents history from being mixed in case a new manufacturer accidentally wants to use an old ID (it would revert and they would need to choose an new ID).
Parameters
Name | Type | Description |
---|---|---|
_manufacturerId | bytes32 | Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name) |
updateManufacturerOwner
function updateManufacturerOwner(bytes32 _manufacturerId, address _newOwner) external
_ONLY MANUFACTURER: Updates the owner address for a manufacturer. Only owner address associated with manufacturerId can call this function.
Parameters
Name | Type | Description |
---|---|---|
_manufacturerId | bytes32 | Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name) |
_newOwner | address | Address of new owner |
isEnrolledChip
function isEnrolledChip(bytes32 _enrollmentId, uint256 _index, address _chipId, bytes32[] _merkleProof) external view returns (bool)
_Validate that _chipId is included in the merkle tree for enrollmentId.
Parameters
Name | Type | Description |
---|---|---|
_enrollmentId | bytes32 | bytes32 identifier of the manaufacturer enrollment |
_index | uint256 | Index of enrollment in the merkle tree |
_chipId | address | Public key associated with the chip |
_merkleProof | bytes32[] | Merkle Proof for _chipId's inclusion in _enrollmentId |
getManufacturerInfo
function getManufacturerInfo(bytes32 _manufacturerId) external view returns (struct ManufacturerRegistry.ManufacturerInfo)
getEnrollmentInfo
function getEnrollmentInfo(bytes32 _enrollmentId) public view returns (struct ManufacturerRegistry.EnrollmentInfo)
getEnrollmentBootloaderApp
function getEnrollmentBootloaderApp(bytes32 _enrollmentId) external view returns (string)