In Romans 1:4 Paul tells us that Jesus Christ “was declared the Son of God with power by the resurrection from the dead, according to the spirit of holiness.” His resurrection by the Spirit proved His sinlessness. If He had any sin of His own, He would have stayed dead as the penalty for that sin.
The affirmation of His perfect righteousness came when the Holy Spirit raised Him from the dead. It may well be that Paul here encompasses both realities. Jesus Christ was vindicated both by His sinless life of obedience to God which declared His righteousness, and by the testimony of the Holy Spirit, who affirmed His righteousness again by raising Him from the dead.