MetaAccess
Introduction
MetaAccess provides a decentralized authorization mechanism to grant access to encrypted on-chain data based on specific rules.
Spec
Two protocols are required: AccessControl and AccessPass.
AccessControl is responsible for setting permissions and control rules. It is published on-chain along with the encrypted content.
AccessPass facilitates payment and authorization transactions, enabling access to decrypted content.
AccessControl
Path: /metaaccess/accesscontrol
AccessPass
Path: /metaaccess/accesspass
Workflow
Creator:
The application requests MAN to generate a public key. MAN generates and stores a key pair, returning the public key (man-publicKey).
The application requests the wallet to perform an ECDH operation using the wallet path and man-publicKey to derive a shared secret (SP).
The application generates a random AES key (P1).
The application edits the text or image, selects the public and paid sections, and sets the payment mode.
Using key P1, the application encrypts the paid content via AES, producing
txRaw
.Using the shared secret SP, the application encrypts key P1 to generate
encrypted-key
and constructs theaccesscontrol
PIN.Both the content PIN and
accesscontrol
PIN are broadcast on-chain.
Buyer:
The application constructs an
accesspass
with an output containing the payment required by theaccesscontrol
.MAN provides an interface to retrieve encrypted content, requiring a wallet-signed header. MAN verifies the signature and retrieves the signed address from the
accesspass
.MAN queries the
accesscontrol
file corresponding to theaccessControlID
and derives the shared secret (SP) using its private key and the creator's public key.MAN validates the
accesspass
against theaccesscontrol
rules. If valid, it proceeds; otherwise, it returns nothing.MAN decrypts the
encrypted-key
using SP to obtain key P1.MAN uses key P1 to decrypt the corresponding
controlPins
and returns the decrypted content.
ECDH Configuration
To ensure proper collaboration between client and server during key exchange, both parties must standardize the following parameters in the ECDH (Elliptic Curve Diffie-Hellman) protocol:
Elliptic Curve Type
Curve:
NIST P-256
(akasecp256r1
orprime256v1
).P-256
provides a balance of security and efficiency.
Public and Private Key Format
Keys are transmitted as Hex-encoded strings.
Public keys are converted to byte arrays using
PublicKey().Bytes()
before Hex encoding; the same applies to private keys.
Key Derivation
Each party generates a public-private key pair, then calculates a shared secret using their private key and the other party's public key.
The derived shared secret is directly usable as the symmetric encryption key.
Symmetric Encryption Configuration (AES)
Algorithm
AES-256-CFB
is used for symmetric encryption.The
CFB (Cipher Feedback)
mode supports streaming encryption and decryption, ideal for shared key environments.
Key Generation
A 256-bit (32-byte) random key is generated using
rand.Read
.Keys are stored and transmitted in Hex-encoded form.
Initialization Vector (IV)
A new 16-byte random IV (AES block size) is generated for each encryption.
The IV is prepended to the ciphertext during transmission for decryption purposes.
Go Code Example
Last updated