Skip to content

Commit

Permalink
Merge pull request #75 from ethereum-attestation-service/salt
Browse files Browse the repository at this point in the history
Add customizable salt to offchain attestations and remove unnecessary offchain attestation version input from the signOffchainAttestation API
  • Loading branch information
lbeder authored Jan 15, 2024
2 parents c374d68 + f364fcb commit bff294c
Show file tree
Hide file tree
Showing 23 changed files with 1,164 additions and 797 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog

## 1.4.0 (2023-12-08)

- Add customizable salt to offchain attestations to reduce the chance of predictable UIDs (which may be abused in some very specific use-cases)
- Remove unnecessary offchain attestation version input from the `signOffchainAttestation` API
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ const attestation = {
},
uid: "0x5134f511e0533f997e569dac711952dde21daf14b316f3cce23835defc82c065",
message: {
version: OffchainAttestationVersion.Version1,
version: OffchainAttestationVersion.Version2,
schema: "0x27d06e3659317e9a4f8154d1e849eb53d43d91fb4f219884d1684f86d797804a",
refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
time: 1671219600,
Expand All @@ -316,7 +316,7 @@ const EAS_CONFIG: PartialTypedDataConfig = {
version: attestation.sig.domain.version,
chainId: attestation.sig.domain.chainId,
};
const offchain = new Offchain(EAS_CONFIG, OffchainAttestationVersion.Version1);
const offchain = new Offchain(EAS_CONFIG, OffchainAttestationVersion.Version2);
const isValidAttestation = offchain.verifyOffchainAttestationSignature(
attestation.signer,
attestation.sig
Expand Down
2 changes: 1 addition & 1 deletion dist/eas.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions dist/offchain/offchain-utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { SignedOffchainAttestation } from './offchain';
export interface SignedOffchainAttestationV1 extends Omit<SignedOffchainAttestation, 'signature'> {
export interface SignedOffchainAttestationV1 extends Omit<SignedOffchainAttestation, 'signature' | 'version'> {
r: string;
s: string;
v: number;
}
export interface AttestationShareablePackageObject {
/** Signed typed data with attestation object */
sig: SignedOffchainAttestation;
/** Address of the signer */
signer: string;
}
export type CompactAttestationShareablePackageObject = [
Expand All @@ -27,7 +25,8 @@ export type CompactAttestationShareablePackageObject = [
revocable: boolean,
data: string,
nonce: number,
offchainVersion?: number
offchainVersion?: number,
salt?: string
];
export declare const createOffchainURL: (pkg: AttestationShareablePackageObject) => string;
export declare const zipAndEncodeToBase64: (pkg: AttestationShareablePackageObject) => string;
Expand Down
49 changes: 38 additions & 11 deletions dist/offchain/offchain-utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/offchain/offchain-utils.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions dist/offchain/offchain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,42 @@ export interface OffchainAttestationType extends EIP712Types<EIP712MessageTypes>
}
export declare enum OffchainAttestationVersion {
Legacy = 0,
Version1 = 1
Version1 = 1,
Version2 = 2
}
export declare const OFFCHAIN_ATTESTATION_TYPES: Record<OffchainAttestationVersion, OffchainAttestationType[]>;
export type OffchainAttestationParams = {
version: number;
schema: string;
recipient: string;
time: bigint;
expirationTime: bigint;
revocable: boolean;
refUID: string;
data: string;
salt?: string;
} & Partial<EIP712Params>;
export type OffchainAttestationTypedData = OffchainAttestationParams & {
version: OffchainAttestationVersion;
};
export type OffchainAttestationOptions = {
salt?: string;
verifyOnchain: boolean;
};
export interface SignedOffchainAttestation extends EIP712Response<EIP712MessageTypes, OffchainAttestationParams> {
export interface SignedOffchainAttestation extends EIP712Response<EIP712MessageTypes, OffchainAttestationTypedData> {
version: OffchainAttestationVersion;
uid: string;
}
export declare const SALT_SIZE = 32;
export declare class Offchain extends TypedDataHandler {
readonly version: OffchainAttestationVersion;
protected signingType: OffchainAttestationType;
protected readonly verificationTypes: OffchainAttestationType[];
private readonly eas;
constructor(config: PartialTypedDataConfig, version: number, eas: EAS);
constructor(config: PartialTypedDataConfig, version: OffchainAttestationVersion, eas: EAS);
getDomainSeparator(): string;
getDomainTypedData(): DomainTypedData;
signOffchainAttestation(params: OffchainAttestationParams, signer: Signer, options?: OffchainAttestationOptions): Promise<SignedOffchainAttestation>;
verifyOffchainAttestationSignature(attester: string, request: SignedOffchainAttestation): boolean;
static getOffchainUID(params: OffchainAttestationParams): string;
verifyOffchainAttestationSignature(attester: string, attestation: SignedOffchainAttestation): boolean;
private getOffchainUID;
static getOffchainUID(version: OffchainAttestationVersion, attestation: SignedOffchainAttestation): string;
}
Loading

0 comments on commit bff294c

Please sign in to comment.