MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / replay_rtmr

Function replay_rtmr

sdk/js/src/index.ts:139–158  ·  view source on GitHub ↗
(history: string[])

Source from the content-addressed store, hash-verified

137}
138
139function replay_rtmr(history: string[]): string {
140 const INIT_MR = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
141 if (history.length === 0) {
142 return INIT_MR
143 }
144 let mr = Buffer.from(INIT_MR, 'hex')
145 for (const content of history) {
146 // Convert hex string to buffer
147 let contentBuffer = Buffer.from(content, 'hex')
148 // Pad content with zeros if shorter than 48 bytes
149 if (contentBuffer.length < 48) {
150 const padding = Buffer.alloc(48 - contentBuffer.length, 0)
151 contentBuffer = Buffer.concat([contentBuffer, padding])
152 }
153 mr = Buffer.from(crypto.createHash('sha384')
154 .update(Buffer.concat([mr, contentBuffer]))
155 .digest())
156 }
157 return mr.toString('hex')
158}
159
160function reply_rtmrs(event_log: EventLog[]): Record<number, string> {
161 const rtmrs: Array<string> = []

Callers 1

reply_rtmrsFunction · 0.70

Calls 2

fromMethod · 0.45
digestMethod · 0.45

Tested by

no test coverage detected