@vocdoni/davinci-sdk 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -142,9 +142,8 @@ interface BallotMode {
142
142
  maxValueSum: string;
143
143
  minValueSum: string;
144
144
  }
145
- interface Census {
145
+ interface CensusData {
146
146
  censusOrigin: CensusOrigin;
147
- maxVotes: string;
148
147
  censusRoot: string;
149
148
  censusURI: string;
150
149
  }
@@ -155,14 +154,13 @@ interface EncryptionKey {
155
154
 
156
155
  interface CreateProcessRequest {
157
156
  processId: string;
158
- censusRoot: string;
157
+ census: {
158
+ censusOrigin: CensusOrigin;
159
+ censusRoot: string;
160
+ censusURI: string;
161
+ };
159
162
  ballotMode: BallotMode;
160
163
  signature: string;
161
- /**
162
- * The censusOrigin specifies the origin type of the census used in the request.
163
- * This attribute allows the API to determine how the census data should be processed or verified.
164
- */
165
- censusOrigin: CensusOrigin;
166
164
  }
167
165
  interface CreateProcessResponse {
168
166
  processId: string;
@@ -181,7 +179,7 @@ interface GetProcessResponse {
181
179
  duration: number;
182
180
  metadataURI: string;
183
181
  ballotMode: BallotMode;
184
- census: Census;
182
+ census: CensusData;
185
183
  metadata: {
186
184
  title: Record<string, string>;
187
185
  description: Record<string, string>;
@@ -235,8 +233,8 @@ interface VoteProof {
235
233
  interface VoteRequest {
236
234
  /** The `processId` you obtained when creating the process. */
237
235
  processId: string;
238
- /** Your Merkle‐proof that you're in the census. */
239
- censusProof: CensusProof;
236
+ /** Your census proof (only required for CSP, not for MerkleTree). */
237
+ censusProof?: CensusProof;
240
238
  /** Your encrypted ballot. */
241
239
  ballot: VoteBallot;
242
240
  /** The zkSNARK proof that the ballot is well‐formed. */
@@ -302,6 +300,10 @@ interface WorkerStats {
302
300
  interface WorkersResponse {
303
301
  workers: WorkerStats[];
304
302
  }
303
+ interface ParticipantInfoResponse {
304
+ key: string;
305
+ weight: string;
306
+ }
305
307
 
306
308
  /**
307
309
  * Creates the signature message for process creation.
@@ -421,6 +423,7 @@ interface CSPSignOutput {
421
423
  censusOrigin: CensusOrigin;
422
424
  root: string;
423
425
  address: string;
426
+ weight: string;
424
427
  processId: string;
425
428
  publicKey: string;
426
429
  signature: string;
@@ -431,7 +434,7 @@ interface RawResult<T = any> {
431
434
  }
432
435
  interface GoDavinciCryptoWasm {
433
436
  proofInputs(inputJson: string): RawResult<DavinciCryptoOutput>;
434
- cspSign(censusOrigin: number, privKey: string, processId: string, address: string): RawResult<CSPSignOutput>;
437
+ cspSign(censusOrigin: number, privKey: string, processId: string, address: string, weight: string): RawResult<CSPSignOutput>;
435
438
  cspVerify(cspProof: string): RawResult<boolean>;
436
439
  cspCensusRoot(censusOrigin: number, privKey: string): RawResult<{
437
440
  root: string;
@@ -491,22 +494,24 @@ declare class DavinciCrypto {
491
494
  * @param privKey - The private key in hex format
492
495
  * @param processId - The process ID in hex format
493
496
  * @param address - The address in hex format
497
+ * @param weight - The vote weight as a decimal string
494
498
  * @returns The CSP proof as a parsed JSON object
495
499
  * @throws if called before `await init()`, or if Go returns an error
496
500
  */
497
- cspSign(censusOrigin: CensusOrigin, privKey: string, processId: string, address: string): Promise<CSPSignOutput>;
501
+ cspSign(censusOrigin: CensusOrigin, privKey: string, processId: string, address: string, weight: string): Promise<CSPSignOutput>;
498
502
  /**
499
503
  * Verify a CSP (Credential Service Provider) proof.
500
504
  * @param censusOrigin - The census origin type (e.g., CensusOrigin.CensusOriginCSP)
501
505
  * @param root - The census root
502
506
  * @param address - The address
507
+ * @param weight - The vote weight as a decimal string
503
508
  * @param processId - The process ID
504
509
  * @param publicKey - The public key
505
510
  * @param signature - The signature
506
511
  * @returns The verification result
507
512
  * @throws if called before `await init()`, or if Go returns an error
508
513
  */
509
- cspVerify(censusOrigin: CensusOrigin, root: string, address: string, processId: string, publicKey: string, signature: string): Promise<boolean>;
514
+ cspVerify(censusOrigin: CensusOrigin, root: string, address: string, weight: string, processId: string, publicKey: string, signature: string): Promise<boolean>;
510
515
  /**
511
516
  * Generate a CSP (Credential Service Provider) census root.
512
517
  * @param censusOrigin - The census origin type (e.g., CensusOrigin.CensusOriginCSP)
@@ -526,6 +531,7 @@ declare class VocdoniSequencerService extends BaseService {
526
531
  submitVote(vote: VoteRequest): Promise<void>;
527
532
  getVoteStatus(processId: string, voteId: string): Promise<VoteStatusResponse>;
528
533
  hasAddressVoted(processId: string, address: string): Promise<boolean>;
534
+ isAddressAbleToVote(processId: string, address: string): Promise<ParticipantInfoResponse>;
529
535
  getInfo(): Promise<InfoResponse>;
530
536
  pushMetadata(metadata: ElectionMetadata): Promise<string>;
531
537
  getMetadata(hashOrUrl: string): Promise<ElectionMetadata>;
@@ -535,4 +541,4 @@ declare class VocdoniSequencerService extends BaseService {
535
541
  }
536
542
 
537
543
  export { CircomProof, DavinciCrypto, VocdoniSequencerService, VoteStatus, createProcessSignatureMessage, signProcessCreation, validateProcessId };
538
- export type { CSPSignOutput, CircomProofOptions, CreateProcessRequest, CreateProcessResponse, DavinciCryptoCiphertext, DavinciCryptoInputs, DavinciCryptoOptions, DavinciCryptoOutput, GetProcessResponse, Groth16Proof, InfoResponse, ListProcessesResponse, ProofInputs, SequencerStats, VoteBallot, VoteCiphertext, VoteProof, VoteRequest, VoteStatusResponse, WorkerStats, WorkersResponse };
544
+ export type { CSPSignOutput, CircomProofOptions, CreateProcessRequest, CreateProcessResponse, DavinciCryptoCiphertext, DavinciCryptoInputs, DavinciCryptoOptions, DavinciCryptoOutput, GetProcessResponse, Groth16Proof, InfoResponse, ListProcessesResponse, ParticipantInfoResponse, ProofInputs, SequencerStats, VoteBallot, VoteCiphertext, VoteProof, VoteRequest, VoteStatusResponse, WorkerStats, WorkersResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocdoni/davinci-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -61,7 +61,7 @@
61
61
  "email": "info@vocdoni.io",
62
62
  "url": "https://vocdoni.io"
63
63
  },
64
- "license": "MIT",
64
+ "license": "AGPL-3.0",
65
65
  "homepage": "https://github.com/vocdoni/davinci-sdk#readme",
66
66
  "repository": {
67
67
  "type": "git",
@@ -72,7 +72,7 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@ethereumjs/common": "^4.4.0",
75
- "@vocdoni/davinci-contracts": "0.0.19",
75
+ "@vocdoni/davinci-contracts": "0.0.26",
76
76
  "axios": "^1.8.4",
77
77
  "ethers": "^6.7.1",
78
78
  "snarkjs": "^0.7.5"