Contracts
ManufacturerRegistry

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:

  1. Unregistered: manufacturers[_manufacturerId].registered = false. This is the default state for all manufacturers.
  2. Registered: manufacturers[_manufacturerId].registered = true && manufacturers[_manufacturerId].owner != address(0).
  3. 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

NameTypeDescription
_governanceaddressAddress 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

NameTypeDescription
_manufacturerIdbytes32Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name)
_merkleRootbytes32Merkle root of all chipIds (addresses) that are valid for this enrollment
_certSigneraddressAddress of certificate signer for this enrollment
_authModeladdressAddress of contract that implements example signature validation for a chip
_chipValidationDataUristringURI pointing to location of off-chain data required to validate chip is part of manufacturer enrollment
_bootloaderAppstringBootloader app for this enrollment
_chipModelstringChip model for this enrollment

Return Values

NameTypeDescription
enrollmentIdbytes32Id 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

NameTypeDescription
_manufacturerIdbytes32Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name)
_owneraddressAddress 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

NameTypeDescription
_manufacturerIdbytes32Bytes32 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

NameTypeDescription
_manufacturerIdbytes32Bytes32 identifier for manufacturer (i.e. could be hash of manufacturer name)
_newOwneraddressAddress 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

NameTypeDescription
_enrollmentIdbytes32bytes32 identifier of the manaufacturer enrollment
_indexuint256Index of enrollment in the merkle tree
_chipIdaddressPublic key associated with the chip
_merkleProofbytes32[]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)