iExec RLC 백서

iExec RLC

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 12쪽 중 10쪽

it dataProtectorCore . getGrantedAccess ({ protectedData : '0x123abc...' , page : 1 , pageSize : 100 , }); pageSize Optional ​ Type: number Default: 20 Range: [10...1000] Specifies the number of records to include in each page of the result set. This is used in conjunction with the optional page parameter to limit the size of each page. Usage example: ts const listGrantedAccess = await dataProtectorCore . getGrantedAccess ({ protectedData : '0x123abc...' , page : 1 , pageSize : 100 , }); bulkOnly Optional ​ Type: boolean Default: false Filter to retrieve only bulk access grants. When set to true , this method returns only granted accesses that were created with allowBulk: true when calling grantAccess . This is useful when preparing bulk requests using prepareBulkRequest . Usage example: ts const { grantedAccess } = await dataProtectorCore . getGrantedAccess ({ bulkOnly : true , }); Return value ​ ts import { type GrantedAccessResponse } from '@iexec/dataprotector' ; The return value for this method has two fields: a count parameter indicating the number of results, and an array of GrantedAccess objects containing all access data. When using the optional paging parameters, the count is limited by the selected pageSize parameter. You may use these result objects in conjunction with the revokeOneAccess method to revoke a previously granted authorization for access. Count ​ Type: number An integer value indicating the number of results returned by this method. This is of particular note when using paging as the number of records returned may be smaller than the page size. grantedAccess ​ git comm Type: GrantedAccess See GrantedAccess ## /references/dataProtector/methods/revokeOneAccess revokeOneAccess ​ This method allows revoking a specific access authorization from a protectedData entity. The input parameter for this method is sourced from the getGrantedAccess method, which provides a list of all authorizations on single protectedData entity. As this will generate a blockchain transaction, expect it to take a least 5sec (a block time). Usage ​ The revokeOneAccess method requires a grantedAccess object as an input parameter. This object is retrieved from the getGrantedAccess method. ts const revokeAccess = await dataProtectorCore . revokeOneAccess ({ apprestrict : '0xea...' , dataset : '0xA0C...' , datasetprice : '0' , requesterrestrict : '0xecb..' , salt : '0x0147...' , sign : '0xc22c1...' , tag : '0x0000000000000000000000000000000000000000000000000000000000000003' , volume : '1' , workerpoolrestrict : '0x000...' , remainingAccess : 1 , }); Parameters ​ ts import { type GrantedAccess } from '@iexec/dataprotector' ; grantedAccess Required * ​ Type: GrantedAccess This is the complete granted access object retrieved from an invocation of getGrantedAccess . ts const revokeAccess = await dataProtectorCore . revokeOneAccess ({ apprestrict : '0xea...' , dataset : '0xA0C...' , datasetprice : '0' , requesterrestrict : '0xecb..' , salt : '0x0147...' , sign : '0xc22c1...' , tag : '0x0000000000000000000000000000000000000000000000000000000000000003' , volume : '1' , workerpoolrestrict : '0x000...' , remainingAccess : 1 , }); WARNING The tag must always be set to 0x0000000000000000000000000000000000000000000000000000000000000003 . This specific value indicates that the order is for a confidential asset (a protected data). Result Value ​ ts import { type RevokedAccess } from '@iexec/dataprotector' ; RevokedAccess ## /references/dataProtector/methods/revokeAllAccess revokeAllAccess ​ This method allows revoking authorizations granted to a protectedData entity. You may optionally specify application or user addresses for revocation. If you do not specify either of these optional values, this method will revoke all access for all users and applications. You must be the owner of the protected data. Under the hood, all granted access will be retrieved and be revoked one by one. If by any chance there were more than 20 granted access to be revoked, you would need to call this revokeAllAccess() method more than once for all granted access to be actually revoked. Use getGrantedAccess() to ensure it is all done. Usage ​ ts const revokeAllAccessResult = await dataProtectorCore . revokeAllAccess ({ protectedData : '0x123abc...' , authorizedApp : '0x456def...' , authorizedUser : '0x789cba...' , }); Parameters ​ ts import { type RevokeAllAccessParams } from '@iexec/dataprotector' ; protectedData Required * ​ Type: Address The address of the protectedData subject to access revocation. ts const revokeAllAccessResult = await dataProtectorCore . revokeAllAccess ({ protectedData : '0x123abc...' , }); authorizedApp Optional ​ Type: Address The application address to be removed from the authorization list for the specified protectedData . If no address is specified, it will revoke all access from the protected data, regardless of the app. ts const revokeAllAccessResult = await dataProtectorCore . revokeAllAccess ({ protectedData : '0x123abc...' , authorizedApp : '0x456def...' , authorizedUser : '0x789cba...' , }); authorizedUser Optional ​ Type: Address The user address to be removed from the authorization list for the specified protectedData . If no address is specified, it will revoke all access from the protected data, regardless of the authorized user. ts const revokeAllAccessResult = await dataProtectorCore . revokeAllAccess ({ protectedData : '0x123abc...' , authorizedApp : '0x456def...' , authorizedUser : '0x789cba...' , }); onStatusUpdate Optional ​ Type: OnStatusUpdateFn<RevokeAllAccessStatuses> Callback function to be notified at intermediate steps. ts const revokeAllAccessResult = await dataProtectorCore . revokeAllAccess ({ protectedData : '0x123abc...' , authorizedApp : '0x456def...' , authorizedUser : '0x789cba...' , onStatusUpdate : ({ title , isDone }) => { console . log ( title , isDone ); }, }); You can expect this callback function to be called with the following titles: ts 'RETRIEVE_ALL_GRANTED_ACCESS' ; 'REVOKE_ONE_ACCESS' ; Once with isDone: false , and then with isDone: true Return Value ​ ts import { type RevokedAccess } from '@iexec/dataprotector' ; RevokedAccess[] ## /references/dataProtector/methods/processProtectedData processProtectedData ​ Allows processing a protected dataset through use of a specified iExec application. IMPORTANT You must ensure this application has authorization to use the protectedData . You may grant this permission using the grantAccess method. Usage ​ ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , args : 'arg1 arg2' , inputFiles : [ 'https://example.com/file1' , 'https://example.com/file2' ], secrets : { 1 : 'secret1' , 2 : 'secret2' , }, }); Parameters ​ ts import { type ProcessProtectedDataParams } from '@iexec/dataprotector' ; protectedData Required * ​ Type: Address The ETH address for the protected data you wish the app to process. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , }); app Required * ​ Type: Address The ETH address for the iExec application to process the protected data. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , }); path Optional ​ Type: string Under the hood, a protected data is a zip file. With this path parameter, you can specify the file you're interested in. The zip file will be uncompressed for you, and only the desired file will be given as the result . ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , path : 'my-content' , }); userWhitelist Optional ​ Type: Address If access to the protected data is granted to a group of users via a whitelist contract, you must use this userWhitelist parameter. The value should be the whitelist contract address that has access to the protected data. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , userWhitelist : '0x656def...' , }); encryptResult Optional ​ Type: boolean Default: false When set to true , the computation result will be encrypted using RSA encryption. This ensures that only you can decrypt and access the result, providing an additional layer of privacy and security for sensitive computation outputs. If encryptResult is true and no pemPrivateKey is provided, a new RSA key pair will be automatically generated. The generated private key will be returned in the response as pemPrivateKey , which you must securely store to decrypt the result later. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , encryptResult : true , }); TIP When encryptResult is enabled, the onStatusUpdate callback will be notified with the following additional status titles: 'GENERATE_ENCRYPTION_KEY' - When a new key pair is being generated 'PUSH_ENCRYPTION_KEY' - When the public key is being pushed to the secrets manager pemPrivateKey Optional ​ Type: string A PEM-formatted RSA private key used to decrypt the encrypted computation result. This parameter can only be used when encryptResult is set to true . If you provide a pemPrivateKey , it will be used to decrypt the result. If you don't provide one but have encryptResult: true , a new key pair will be generated automatically, and the private key will be returned in the response for you to store securely. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , encryptResult : true , pemPrivateKey : '-----BEGIN PRIVATE KEY----- \n ... \n -----END PRIVATE KEY-----' , }); DANGER If you provide a pemPrivateKey , you must also set encryptResult: true . The method will throw a validation error if pemPrivateKey is provided without encryptResult being enabled. TIP The pemPrivateKey (whether provided or auto-generated) will be included in the response object when encryptResult is true . Make sure to securely store this key if you need to decrypt the result later using the getResultFromCompletedTask() method. args Optional ​ Type: string Set of execution arguments for the application. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , args : 'arg1 arg2' , }); DANGER Do not use this to provide any sensitive information to the application. All arguments passed this way are visible in plain text using the iExec explorer . inputFiles Optional ​ Type: string[] A set of URLs representing the input files required for application execution. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , inputFiles : [ 'https://example.com/file1' , 'https://example.com/file2' ], }); secrets Optional ​ Type: Record<number, string> A set of requester secrets necessary for the application's execution. This is represented as a mapping of numerical identifiers to corresponding secrets stored in the secrets manager needed for the application's execution. Secrets are accessible during the application's execution as environment variables. For more details, see Access requester secrets . ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , secrets : { 1 : 'secret1' , 2 : 'secret2' , }, }); workerpool Optional ​ Type: Address | 'any' Default: 0x8ef2ec3ef9535d4b4349bfec7d8b31a580e60244 It's the confidential computer on which the iExec application will run. TIP iExec currently offers a workerpool located at the address 0x8ef2ec3ef9535d4b4349bfec7d8b31a580e60244 . This is the default workerpool for running confidential computations on the iExec platform. TDX @iexec/dataprotector uses Intel TDX to process protected data. Connect to the TDX SMS and use the TDX workerpool : Browser ts import { IExecDataProtectorCore } from '@iexec/dataprotector' ; const web3Provider = window . ethereum ; // Instantiate dataProtector connected to the TDX SMS const dataProtectorCore = new IExecDataProtectorCore ( web3Provider , { iexecOptions : { smsURL : 'https://sms.labs.iex.ec' , }, }); const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , workerpool : '0x2956f0cb779904795a5f30d3b3ea88b714c3123f' , }); ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , workerpool : '0xa5de76...' , }); dataMaxPrice Optional ​ Type: number Default: 0 Allows specifying the maximum amount (in nRLC) you are willing to pay the protected data owner for using their data. The owner of the protected data receives this as a payment for sharing their data. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , dataMaxPrice : 42 , }); appMaxPrice Optional ​ Type: number Default: 0 Allows specifying the maximum amount (in nRLC) you are willing to pay the iApp provider for using the deployed application. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , appMaxPrice : 42 , }); workerpoolMaxPrice Optional ​ Type: number Default: 0 Allows specifying the maximum amount you want to pay the workerpool provider for using their infrastructure to run the iApp in nRLC. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , workerpoolMaxPrice : 42 , }); onStatusUpdate Optional ​ Type: OnStatusUpdateFn<ProcessProtectedDataStatuses> Callback function to be notified at intermediate steps. ts const processProtectedDataResponse = await dataProtectorCore . processProtectedData ({ protectedData : '0x123abc...' , app : '0x456def...' , onStatusUpdate : ({ title , isDone }) => { console . log ( title , isDone ); }, }); You can expect this callback function to be called with the following titles: ts 'FETCH_ORDERS' ; 'PUSH_REQUESTER_SECRET' ; 'GENERATE_ENCRYPTION_KEY' ; 'PUSH_ENCRYPTION_KEY' ; 'REQUEST_TO_PROCESS_PROTECTED_DATA' ; 'TASK_EXECUTION' ; 'CONSUME_TASK' ; 'CONSUME_RESULT_DOWNLOAD' ; 'CONSUME_RESULT_DECRYPT' ; Once with isDone: false , and then with isDone: true INFO The 'GENERATE_ENCRYPTION_KEY' and 'PUSH_ENCRYPTION_KEY' status titles are only triggered when encryptResult is set to true . Return Value ​ ts import { type ProcessProtectedDataResponse } from '@iexec/dataprotector' ; txHash ​ string The ID of the transaction that happened on iExec's side chain. You may view details on the transaction using the iExec explorer . dealId ​ string Identifies the specific deal associated with this transaction. taskId ​ string A unique identifier associated with a task currently running on the iExec protocol. You can monitor task execution using the iExec explorer . TIP The getResultFromCompletedTask() function allows you to retrieve the result of a completed task using its taskId . Additionally, you can specify a file path within the ZIP archive to extract a specific file when required. result ​ ArrayBuffer The result is a ZIP file containing at least one mandatory file: computed.json : This file contains metadata about the computation performed by the application. additional files may be included depending on the dapp used. INFO In the case of the Content Creator Delivery DApp , the ZIP file will also include a file named content , which corresponds to the protected data processed during the task. pemPrivateKey ​ string The PEM-formatted RSA private key used to decrypt the encrypted computation result. This property is only present in the response when encryptResult is set to true . If you provided a pemPrivateKey in the parameters, the same key will be returned. If you didn't provide one but enabled encryptResult , a newly generated private key will be returned, which you must securely store to decrypt the result. TIP You can use this pemPrivateKey with the getResultFromCompletedTask() method to decrypt and retrieve the result of a completed task. ## /references/dataProtector/methods/prepareBulkRequest prepareBulkRequest ​ This method prepares a bulk request by grouping multiple protected data items that can be processed together efficiently. The prepared bulk request can then be processed using the processBulkRequest method. INFO This method is part of a two-step bulk processing process: Prepare the bulk request using prepareBulkRequest to create a bulk request Process the bulk request using processBulkRequest to execute the bulk processing Usage ​ Browser NodeJS ts import { IExecDataProtectorCore } from '@iexec/dataprotector' ; const web3Provider = window . ethereum ; const dataProtectorCore = new IExecDataProtectorCore ( web3Provider ); // Get granted accesses with bulk capability const { grantedAccess } = await dataProtectorCore . getGrantedAccess ({ bulkOnly : true , }); // Prepare the bulk request const { bulkRequest } = await dataProtectorCore . prepareBulkRequest ({ bulkAccesses : grantedAccess , app : '0x456def...' , maxProtectedDataPerTask : 100 , }); ts import { IExecDataProtectorCore , getWeb3Provider } from '@iexec/dataprotector' ; const web3Provider = getWeb3Provider ( 'PRIVATE_KEY' , 'RPC_URL' ); const dataProtectorCore = new IExecDataProtectorCore ( web3Provider ); // Get granted accesses with bulk capability const { grantedAccess } = await dataProtectorCore . getGrantedAccess ({ bulkOnly : true , }); // Prepare the bulk request const { bulkRequest } = await dataProtectorCore . prepareBulkRequest ({ bulkAccesses : grantedAccess , app : '0x456def...' , maxProtectedDataPerTask : 100 , }); Parameters ​ ts import { type PrepareBulkRequestParams } from '@iexec/dataprotector' ; bulkAccesses Required * ​ Type: GrantedAccess[] An array of GrantedAccess objects representing protected data items that have been granted access with bulk processing capability. Use bulkOnly: true option in getGrantedAccess to obtain bulk accesses. Each GrantedAccess must have been created with allowBulk: true when calling grantAccess . ts const { bulkRequest } = await dataProtectorCore . prepareBulkRequest ({ bulkAccesses : grantedAccess , app : '0x456def...' , }); app Required * ​ Type: Address The ETH address for the iExec application that will process the protected data items in the bulk request. ts const { bulkRequest } = await dataProtectorCore . prepareBulkRequest ({ bulkAccesses : grantedAccess , app : '0x456def...' , }); maxProtectedDataPerTask Optional ​ Type: number | undefined Default: 100 Limits the number of protected data items processed per task. If you have more protected data items than this limit, multiple tas
프로젝트로 돌아가기