Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add customizable salt to offchain attestations and remove unnecessary offchain attestation version input from the signOffchainAttestation API #75

Merged
merged 8 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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